At the reflection level, the only place that it exists is in the body of the constructor method, which compiles as ( HelloMessage
):
.method public hidebysig specialname rtspecialname instance void
.ctor(string name) cil managed
{
.maxstack 8
L_0000: ldarg.0
L_0001: ldstr "Hello {0}"
L_0006: ldc.i4.1
L_0007: newarr string
L_000c: dup
L_000d: ldc.i4.0
L_000e: ldarg.1
L_000f: stelem.ref
L_0010: call instance void BaseMessage::.ctor(string, string[])
L_0015: ret
}
or ( IntroductionMessage
):
.method public hidebysig specialname rtspecialname instance void
.ctor(string name, string myName) cil managed
{
.maxstack 8
L_0000: ldarg.0
L_0001: ldstr "Hello {0}, I am {1}"
L_0006: ldc.i4.2
L_0007: newarr string
L_000c: dup
L_000d: ldc.i4.0
L_000e: ldarg.1
L_000f: stelem.ref
L_0010: dup
L_0011: ldc.i4.1
L_0012: ldarg.2
L_0013: stelem.ref
L_0014: call instance void BaseMessage::.ctor(string, string[])
L_0019: ret
}
, (MethodInfo.GetMethodBody().GetILAsByteArray()
) (, IL, , ). , , , , . IL, ... : .
:
- ,
format
BaseMessage
- , , Roslyn -
- -, ; .