111,126
社区成员
发帖
与我相关
我的任务
分享
int i = 10;
object o=new object();
//(1)
Console.WriteLine(i.ToString() + "," + o);
//(2)
Console.WriteLine(i + "," + o);
//(1)的IL代码
IL_000c: call instance string [mscorlib]System.Int32::ToString()
IL_0011: ldstr ","
IL_0016: ldloc.1
IL_0017: call string [mscorlib]System.String::Concat(object,
object,
object)
IL_001c: call void [mscorlib]System.Console::WriteLine(string)
//(2)的IL代码
IL_0023: box [mscorlib]System.Int32
IL_0028: ldstr ","
IL_002d: ldloc.1
IL_002e: call string [mscorlib]System.String::Concat(object,
object,
object)
IL_0033: call void [mscorlib]System.Console::WriteLine(string)