STATIC_READONLY_STRING = CONST_STRING =
Compile and run:
C: \ Users \ de \ Desktop \ bao> csc/t: library/nologo ClassA1.cs
C: \ Users \ de \ Desktop \ bao> csc/r: ClassA1.dll/nologo ClassB1.cs
C: \ Users \ de \ Desktop \ bao> ClassB1
ClassA1.CONST _ STRING = CONST_STRING
ClassA1.STATIC _ READONLY_STRING = STATIC_READONLY_STRING
C: \ Users \ de \ Desktop \ bao>
Reedit ClassA1.cs
STATIC_READONLY_STRING = CONST_STRING =
Recompile classa1.csand run classb1.exe:
C: \ Users \ de \ Desktop \ bao> csc/t: library/nologo ClassA1.cs
C: \ Users \ de \ Desktop \ bao> ClassB1
ClassA1.CONST _ STRING =
ClassA1.STATIC _ READONLY_STRING =
C: \ Users \ de \ Desktop \ bao>
????
Decompress classb1.exe
C: \ Users \ de \ Desktop \ bao> ildasm
C: \ Users \ de \ Desktop \ bao>
After classb1.exe is opened, view/metainfo/show! (Ctrl + M)
There is such a section at the bottom of metainfo:
User Strings
-------------------------------------------------------
70000001: (64) L "ClassA1.CONST _ STRING = {0} \ r \ nClassA1.STATIC _ READONLY_STRING = {1 }"
70000084: (12) L ""
And the IL code corresponding to ClassB1.ShowClassA1
. Method public hidebysig static void ShowClassA1 () cel managed
{
// Code size 23 (0x17)
. Maxstack 8
IL_0000: nop
IL_0001: ldstr "ClassA1.CONST _ STRING = {0} \ r \ nClassA1.STATIC _ READONL"
+ "Y_STRING = {1 }"
IL_0006:
IL_000b:
IL_0010: call void [mscorlib] System. Console: WriteLine (string,
Object,
Object)
IL_0015: nop
IL_0016: ret
} // End of method ClassB1: ShowClassA1
Conclusion:. NET string resident Mechanism