私は現在ILコードを使用しており、将来は自分で作成する必要があります。誤解のために私が持っているいくつかの懸念があります。これがC#の簡単な方法です
public static string Method1(int id)
{
return Method2(id);
}
これがそのILコードです
.method public hidebysig static string
Method1(int32 id) cil managed
{
//
.maxstack 1
.locals init ([0] string CS$1$0000)
IL_0000: nop // Why?
IL_0001: ldarg.0
IL_0002: call string MyNamespace.MyClass::Method2(int32)
IL_0007: stloc.0 // storing a return value of MyClass::Method2 to local variable.
IL_0008: br.s IL_000a // Why?
IL_000a: ldloc.0 // Does it really require and why?
IL_000b: ret
} // end of method MyClass::Method1
CILの各nop
メソッドには、何らかの理由で動作があります。なぜそれがあるのですか?私の場合、使用する必要があり、それbr.s IL_000a
がなくても機能しますか?