namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
int a = M();
int M()
{
return 1;
}
}
}
}
![](https://img-blog.csdnimg.cn/img_convert/93a5b46f0b166fd22c7bc1742d2fe9a8.gif)
![](https://img-blog.csdnimg.cn/img_convert/9c97fc2fa9e70ef810941a3c0b1e623e.gif)
.class private auto ansi beforefieldinit ConsoleApp1.Program
extends [mscorlib]System.Object
{
// Methods
.method private hidebysig static
void Main (
string[] args
) cil managed
{
// Method begins at RVA 0x2050
// Header size: 12
// Code size: 9 (0x9)
.maxstack 1
.entrypoint
.locals init (
[0] int32 a
)
IL_0000: nop
IL_0001: call int32 ConsoleApp1.Program::'<Main>g__M|0_0'()
IL_0006: stloc.0
IL_0007: nop
IL_0008: ret
} // end of method Program::Main
.method public hidebysig specialname rtspecialname
instance void .ctor () cil managed
{
// Method begins at RVA 0x2065
// Header size: 1
// Code size: 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method Program::.ctor
.method assembly hidebysig static
int32 '<Main>g__M|0_0' () cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = (
01 00 00 00
)
// Method begins at RVA 0x2070
// Header size: 12
// Code size: 7 (0x7)
.maxstack 1
.locals init (
[0] int32
)
IL_0000: nop
IL_0001: ldc.i4.1
IL_0002: stloc.0
IL_0003: br.s IL_0005
IL_0005: ldloc.0
IL_0006: ret
} // end of method Program::'<Main>g__M|0_0'
} // end of class ConsoleApp1.Program
以下不是内联函数
![](https://img-blog.csdnimg.cn/img_convert/39962a726f0edfc2959111a8ff774183.gif)
![](https://img-blog.csdnimg.cn/img_convert/716e8abce42bf4c18ea6d05a8312ba5b.gif)
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
int a = M();
}
static int M()
{
return 1;
}
}
}
![](https://img-blog.csdnimg.cn/img_convert/71112f4cab3d91b70fc46709f6627483.gif)
![](https://img-blog.csdnimg.cn/img_convert/7b01c0fa1bc0de262fdcb87544ec25b8.gif)
.namespace ConsoleApp1
{
.class private auto ansi beforefieldinit ConsoleApp1.Program
extends [mscorlib]System.Object
{
// Methods
.method private hidebysig static
void Main (
string[] args
) cil managed
{
// Method begins at RVA 0x2050
// Header size: 12
// Code size: 8 (0x8)
.maxstack 1
.entrypoint
.locals init (
[0] int32 a
)
IL_0000: nop
IL_0001: call int32 ConsoleApp1.Program::M()
IL_0006: stloc.0
IL_0007: ret
} // end of method Program::Main
.method private hidebysig static
int32 M () cil managed
{
// Method begins at RVA 0x2064
// Header size: 12
// Code size: 7 (0x7)
.maxstack 1
.locals init (
[0] int32
)
IL_0000: nop
IL_0001: ldc.i4.1
IL_0002: stloc.0
IL_0003: br.s IL_0005
IL_0005: ldloc.0
IL_0006: ret
} // end of method Program::M
.method public hidebysig specialname rtspecialname
instance void .ctor () cil managed
{
// Method begins at RVA 0x2077
// Header size: 1
// Code size: 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method Program::.ctor
} // end of class ConsoleApp1.Program
}