optimization - Will the C# compiler remove unused local if it is assigned a property? -


this might silly question. know compiler remove unused locals. if write code this:

class myclass {     public int someproperty     {                 {           ...         }     }      public void somefunction ()     {        //will line removed if never used?        int = someproperty;        ...     } } 

i wondering if i removed compiler because of optimization. there logic inside getter of someproperty wish execute. if i removed, have change someproperty function.

btw, there way know line optimized compiler?

i suggest compiler not important. bad design.

if calling getter has important side effects should not getter. getter should doing lazy initialising , shouldn't important since if doesn't happen done next thing it.

i don't know doing should refactored own method can called explicitly @ point.

the other major concern relate readability. seeing line int = someproperty; when i never used again might decide line pointless , nothing , remove code causing whatever unexpected errors arise. better off calling method logicextractedfromproperty() obvious doing something.

the compiler might (or might not, don't know or care) right thing person may not.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -