我想你會發現它們導致相同的IL。
更新:
PropertyChanged += new PropertyChangedEventHandler(SomeEventHandler);
PropertyChanged += SomeEventHandler;
在IL結果使用反彙編:
IL_0006: l4zyOP
IL_0007: nop
//000011: PropertyChanged += new PropertyChangedEventHandler(SomeEventHandler);
IL_0008: ldarg.0
IL_0009: ldarg.0
IL_000a: ldftn instance void StackOverflow_5535253.SomeClass::SomeEventHandler(object, class [System]System.ComponentModel.PropertyChangedEventArgs)
IL_0010: newobj instance void [System]System.ComponentModel.PropertyChangedEventHandler::.ctor(object, native int)
IL_0015: call instance void StackOverflow_5535253.SomeClass::add_PropertyChanged(class [System]System.ComponentModel.PropertyChangedEventHandler)
IL_001a: nop
//000012: PropertyChanged += SomeEventHandler;
IL_001b: ldarg.0
IL_001c: ldarg.0
IL_001d: ldftn instance void StackOverflow_5535253.SomeClass::SomeEventHandler(object, class [System]System.ComponentModel.PropertyChangedEventArgs)
IL_0023: newobj instance void [System]System.ComponentModel.PropertyChangedEventHandler::.ctor(object, native int)
IL_0028: call instance void StackOverflow_5535253.SomeClass::add_PropertyChanged(class [System]System.ComponentModel.PropertyChangedEventHandler)
IL_002d: nop
你證實了你自己嗎?如果是這樣,我很樂意看到一個例子。如果你發佈一個,那就是它顯示的內容,你會得到答案。 – MarqueIV 2011-04-04 06:47:24