> delegate void TheDelegate ( int i ); > class Program > { > > > > > static void xx(int i) > { > } > > static void yy(int i) > { > } > > static void zz(int i) > { > } > static void Main(string[] args) > { > > TheDelegate chain = null ; > chain = chain + xx + yy + zz; > > > return; > } > } >>
>.method private hidebysig static void Main(string[] args) cil managed >{ > .entrypoint > // Code size 74 (0x4a) > .maxstack 4 > .locals init ([0] class CoreTest.TheDelegate chain) > IL_0000: nop > IL_0001: ldnull > IL_0002: stloc.0 > IL_0003: ldloc.0 > IL_0004: ldnull > IL_0005: ldftn void CoreTest.Program::xx(int32) > IL_000b: newobj instance void CoreTest.TheDelegate::.ctor(object, > native int) > IL_0010: call class [mscorlib]System.Delegate [mscorlib]System.Delegate::Combine(class [mscorlib]System.Delegate, > class [mscorlib]System.Delegate) > IL_0015: castclass CoreTest.TheDelegate > IL_001a: ldnull > IL_001b: ldftn void CoreTest.Program::yy(int32) > IL_0021: newobj instance void CoreTest.TheDelegate::.ctor(object, > native int) > IL_0026: call class [mscorlib]System.Delegate [mscorlib]System.Delegate::Combine(class [mscorlib]System.Delegate, > class [mscorlib]System.Delegate) > IL_002b: castclass CoreTest.TheDelegate > IL_0030: ldnull > IL_0031: ldftn void CoreTest.Program::zz(int32) > IL_0037: newobj instance void CoreTest.TheDelegate::.ctor(object, > native int) > IL_003c: call class [mscorlib]System.Delegate [mscorlib]System.Delegate::Combine(class [mscorlib]System.Delegate, > class [mscorlib]System.Delegate) > IL_0041: castclass CoreTest.TheDelegate > IL_0046: stloc.0 > IL_0047: br.s IL_0049 > IL_0049: ret >} // end of method Program::Main >Interesting again - but there doesn't seem to be any optimization there ? From http://msdn.microsoft.com/en-us/library/system.delegate.aspx: