Compilation Keyword Performance

Refactoring a Large Project (in terms of lines of code) I got introduced to ReSharper and the theme using var instead of a type that will only affect at compile time. Does this significantly affect compile time? I would like to define a code style for it in my company, but I'm not sure if I like the idea of ​​"overusing" the var keyword ...

+3


source to share


2 answers


In my experience, any difference is negligible for non-observability. I cannot find any difference, even in large projects. Whatever difference var makes is statistically insignificant, and is lost in the rest of the compilation.



+3


source


This has no effect, since var is resolved at compile time, since C # is a static language.


At compile time, the compiler replaces the actual type where var is in the code. So little impact on the compiler of compiling the code

Example:



var s = "hi";

      

is replaced by

string s = "hi";

      

+2


source







All Articles