static void Main(string[] args)
{
Console.Write("\nEnter a double");
string input=Console.ReadLine();
double num=Double.Parse(input);
Console.Write("Enter another double");
input=Console.ReadLine();
double denom=Double.Parse(input);
double res=num/denom;
Console.WriteLine("Result is {0}",res);
}下面是对上面代码用ildasm.exe反编译的结果,哪个大哥帮我详细的解释一下啊,就这摸点分了,全部奉上
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 )
// 代码大小 67 (0x43)
.maxstack 2
.locals init ([0] string input,
[1] float64 num,
[2] float64 denom,
[3] float64 res)
IL_0000: ldstr "\nEnter a double"
IL_0005: call void [mscorlib]System.Console::Write(string)
IL_000a: call string [mscorlib]System.Console::ReadLine()
IL_000f: stloc.0
IL_0010: ldloc.0
IL_0011: call float64 [mscorlib]System.Double::Parse(string)
IL_0016: stloc.1
IL_0017: ldstr "Enter another double"
IL_001c: call void [mscorlib]System.Console::Write(string)
IL_0021: call string [mscorlib]System.Console::ReadLine()
IL_0026: stloc.0
IL_0027: ldloc.0
IL_0028: call float64 [mscorlib]System.Double::Parse(string)
IL_002d: stloc.2
IL_002e: ldloc.1
IL_002f: ldloc.2
IL_0030: div
IL_0031: stloc.3
IL_0032: ldstr "Result is {0}"
IL_0037: ldloc.3
IL_0038: box [mscorlib]System.Double
IL_003d: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0042: ret
} // end of method Class1::Main
{
Console.Write("\nEnter a double");
string input=Console.ReadLine();
double num=Double.Parse(input);
Console.Write("Enter another double");
input=Console.ReadLine();
double denom=Double.Parse(input);
double res=num/denom;
Console.WriteLine("Result is {0}",res);
}下面是对上面代码用ildasm.exe反编译的结果,哪个大哥帮我详细的解释一下啊,就这摸点分了,全部奉上
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 )
// 代码大小 67 (0x43)
.maxstack 2
.locals init ([0] string input,
[1] float64 num,
[2] float64 denom,
[3] float64 res)
IL_0000: ldstr "\nEnter a double"
IL_0005: call void [mscorlib]System.Console::Write(string)
IL_000a: call string [mscorlib]System.Console::ReadLine()
IL_000f: stloc.0
IL_0010: ldloc.0
IL_0011: call float64 [mscorlib]System.Double::Parse(string)
IL_0016: stloc.1
IL_0017: ldstr "Enter another double"
IL_001c: call void [mscorlib]System.Console::Write(string)
IL_0021: call string [mscorlib]System.Console::ReadLine()
IL_0026: stloc.0
IL_0027: ldloc.0
IL_0028: call float64 [mscorlib]System.Double::Parse(string)
IL_002d: stloc.2
IL_002e: ldloc.1
IL_002f: ldloc.2
IL_0030: div
IL_0031: stloc.3
IL_0032: ldstr "Result is {0}"
IL_0037: ldloc.3
IL_0038: box [mscorlib]System.Double
IL_003d: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0042: ret
} // end of method Class1::Main
maxstack 堆栈上的项的最大数目
ldstr 推送对元数据中存储的字符串的新对象引用
stloc 从计算堆栈的顶部弹出当前值并将其存储到指定索引处的局部变量列表中
div 将两个值相除并将结果作为浮点(F 类型)或商(int32 类型)推送到计算堆栈上
box 装箱
IL_0000: ldstr "\nEnter a double"
IL_0005: call void [mscorlib]System.Console::Write(string)
IL_000a: call string [mscorlib]System.Console::ReadLine()
IL_000f: stloc.0
IL_0010: ldloc.0
IL_0011: call float64 [mscorlib]System.Double::Parse(string)
IL_0016: stloc.1
IL_0017: ldstr "Enter another double"
IL_001c: call void [mscorlib]System.Console::Write(string)
IL_0021: call string [mscorlib]System.Console::ReadLine()
IL_0026: stloc.0
IL_0027: ldloc.0
IL_0028: call float64 [mscorlib]System.Double::Parse(string)
IL_002d: stloc.2
IL_002e: ldloc.1
IL_002f: ldloc.2
IL_0030: div
IL_0031: stloc.3
IL_0032: ldstr "Result is {0}"
IL_0037: ldloc.3
IL_0038: box [mscorlib]System.Double
IL_003d: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0042: ret
IL_0000: ldstr "\nEnter a double"
IL_0005: call void [mscorlib]System.Console::Write(string)
IL_000a: call string [mscorlib]System.Console::ReadLine()
IL_000f: stloc.0
IL_0010: ldloc.0
IL_0011: call float64 [mscorlib]System.Double::Parse(string)
IL_0016: stloc.1
IL_0017: ldstr "Enter another double"
IL_001c: call void [mscorlib]System.Console::Write(string)
IL_0021: call string [mscorlib]System.Console::ReadLine()
IL_0026: stloc.0
IL_0027: ldloc.0
IL_0028: call float64 [mscorlib]System.Double::Parse(string)
IL_002d: stloc.2
IL_002e: ldloc.1
IL_002f: ldloc.2
IL_0030: div
IL_0031: stloc.3
IL_0032: ldstr "Result is {0}"
IL_0037: ldloc.3
IL_0038: box [mscorlib]System.Double
IL_003d: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0042: ret
同时接分