What memory is for constants defined in the method?

To someone, I could describe what happens (in terms of memory management) when a constant is defined inside method c. Net?

+5
source share
2 answers

Constants are usually resolved at compile time and are directly inserted into the sequence of commands. Example:

const int A = 10;
int b;

int i = A + b;

will be effectively compiled into:

int i = 10 + b;

For strings, they are interned and put in a heap.

+7
source

#, (IL), , , . const l- . Msdn.

+1

All Articles