Click here to Skip to main content
15,851,453 members
Home / Discussions / C#
   

C#

 
GeneralRe: Request help for 2 newbie questions Pin
Heath Stewart30-Jan-04 5:51
protectorHeath Stewart30-Jan-04 5:51 
GeneralRe: Request help for 2 newbie questions Pin
Mazdak30-Jan-04 6:00
Mazdak30-Jan-04 6:00 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 6:06
bouli30-Jan-04 6:06 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 6:10
bouli30-Jan-04 6:10 
GeneralRe: Request help for 2 newbie questions Pin
Heath Stewart30-Jan-04 6:24
protectorHeath Stewart30-Jan-04 6:24 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 6:28
bouli30-Jan-04 6:28 
GeneralRe: Request help for 2 newbie questions Pin
TuringTest13-Feb-04 23:55
TuringTest13-Feb-04 23:55 
GeneralRe: Request help for 2 newbie questions Pin
Heath Stewart4-Feb-04 4:35
protectorHeath Stewart4-Feb-04 4:35 
Consider this: when you override such a method like OnPaint, the CLR will call your virtual method which uses the callvirt (as opposed to call) IL instruction. This is polymorphism. This one call does it all. When you instead handle an event in the derived class from the base class (like handling the Paint) event, there are several IL instructions (both in your implementation and in the event's add and remove accessors, not to mention whatever they require to add the handler to the callback chain) just to wire-up the event! When the event is fired, the collection of handlers is enumerated and each one is invoked with takes several more IL instructions (some to enumerate and jump back, and a couple to invoke the delegate). I hope this makes sense.

Besides, when you override the event handler like OnPaint, you don't need to know the sender because the current instance of your class is the sender. All you need is the EventArgs (or derivative, like PaintEventArgs). It simplifies your class.

 

Microsoft MVP, Visual C#
My Articles
Generalpdf printing Pin
amadeonMk30-Jan-04 3:41
amadeonMk30-Jan-04 3:41 
GeneralRe: pdf printing Pin
Heath Stewart30-Jan-04 5:47
protectorHeath Stewart30-Jan-04 5:47 
GeneralRe: pdf printing Pin
amadeonMk30-Jan-04 9:02
amadeonMk30-Jan-04 9:02 
GeneralRe: pdf printing Pin
Heath Stewart30-Jan-04 10:39
protectorHeath Stewart30-Jan-04 10:39 
QuestionWhere should I start studying for Managed DirectX if I'm a n00b? Pin
C# n00b30-Jan-04 2:27
C# n00b30-Jan-04 2:27 
AnswerRe: Where should I start studying for Managed DirectX if I'm a n00b? Pin
Mazdak30-Jan-04 2:35
Mazdak30-Jan-04 2:35 
GeneralRe: Where should I start studying for Managed DirectX if I'm a n00b? Pin
C# n00b30-Jan-04 2:42
C# n00b30-Jan-04 2:42 
GeneralRe: Where should I start studying for Managed DirectX if I'm a n00b? Pin
Mazdak30-Jan-04 2:54
Mazdak30-Jan-04 2:54 
GeneralPrinting Problem Pin
cjengler30-Jan-04 2:13
cjengler30-Jan-04 2:13 
GeneralWell now I'm convinced Pin
Rob Manderson29-Jan-04 23:41
protectorRob Manderson29-Jan-04 23:41 
GeneralRe: Well now I'm convinced Pin
Stephane Rodriguez.30-Jan-04 0:24
Stephane Rodriguez.30-Jan-04 0:24 
GeneralRe: Well now I'm convinced Pin
Brian Delahunty30-Jan-04 4:12
Brian Delahunty30-Jan-04 4:12 
GeneralRe: Well now I'm convinced Pin
Stephane Rodriguez.30-Jan-04 5:49
Stephane Rodriguez.30-Jan-04 5:49 
GeneralRe: Well now I'm convinced Pin
Brian Delahunty30-Jan-04 6:45
Brian Delahunty30-Jan-04 6:45 
GeneralRe: Well now I'm convinced Pin
Stephane Rodriguez.30-Jan-04 7:08
Stephane Rodriguez.30-Jan-04 7:08 
GeneralGDI+ problem (tough!) Pin
r929-Jan-04 23:38
r929-Jan-04 23:38 
GeneralRe: GDI+ problem (tough!) Pin
r929-Jan-04 23:39
r929-Jan-04 23:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.