且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MVC概念帮助 - 将内联代码更改为方法

更新时间:2023-02-16 20:47:58

我倾向于在我的项目中总是有一个Util类,我可能会在多个地方使用静态方法。如果仅对此模型需要此代码,请将其放在模型类上。总的来说,我不知道为什么你在飞行中创建位图无论如何?



你可以改善这样的逻辑:



I tend to always have a Util class in my project, with static methods I am likely to use in more than one place. If this code is needed only for this model, put it on the model class. Overall I am at a loss as to why you're creating bitmaps on the fly anyhow ?

You can improve your logic like this:

if (titem.SStart == null)
                   { c = 0; }
                   else if (titem.SEnd == null)
                   { c = 1; }
                   else if (titem.SCert == null)
                   { c = 2; }
                   else 
                   { c = 3; }







你仔细检查已经检查过的东西,当你知道它是真的到他们那里。




You're double checking things you already checked and know to be true by the time you get to them.