cpp
.assembly extern mscorlib {}
.assembly Methods
{
.ver 1:0:1:0
}
.module Methods.exe
.method static void main() cil managed
{
.maxstack 5
.entrypoint
ldc.i4 101
ldc.i4 202
call int32 DoSum(int32, int32)
call void PrintSum(int32)
ret
}
.method public static int32 DoSum (int32 , int32 ) cil managed
{
.maxstack 2
ldarg.0
ldarg.1
add
ret
}
.method public static void PrintSum(int32) cil managed
{
.maxstack 2
ldstr "The Result is : "
call void [mscorlib]System.Console::Write(string)
ldarg.0
call void [mscorlib]System.Console::Write(int32)
ret
}
构建运行如下;
代码定义了2个方法;
调用的时候指明返回类型和参数类型;
和C#语言相比,方法名前面加了.method,后面加了 cil managed;
这是网上的程序;我还不是太理解;目前还不能写一个方法,比如说是计算阶乘之类的;