Why are const
usages replaced by their values on compile time but then still included in the assembly? At least this is what IL DASM and Reflector shows.
Currently I am using const
for defining many magic numbers and strings to easier be able to change code without affecting run-time performance.
Now I know that that doesnt affect the used memory but it still affects compiled assembly size which is crucial for example for mobile phone apps.
Another disadvantage is that other people easier understand magic numbers when looking at the disassembled code.
I am really interested in why the compiler (Mono as well as .NET) does this exactly?