Click here to Skip to main content
15,891,669 members
Home / Discussions / C#
   

C#

 
QuestionAnyone Know a better way ? Pin
Guinness4Strength30-Jan-04 3:49
Guinness4Strength30-Jan-04 3:49 
AnswerRe: Anyone Know a better way ? Pin
Heath Stewart30-Jan-04 4:59
protectorHeath Stewart30-Jan-04 4:59 
GeneralRe: Path.Combine Pin
Mike Osbahr30-Jan-04 9:19
Mike Osbahr30-Jan-04 9:19 
GeneralRequest help for 2 newbie questions Pin
bouli30-Jan-04 3:06
bouli30-Jan-04 3:06 
GeneralRe: Request help for 2 newbie questions Pin
Wizard_0130-Jan-04 3:23
Wizard_0130-Jan-04 3:23 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 3:31
bouli30-Jan-04 3:31 
GeneralRe: Request help for 2 newbie questions Pin
Mazdak30-Jan-04 3:40
Mazdak30-Jan-04 3:40 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 3:42
bouli30-Jan-04 3:42 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 3:54
bouli30-Jan-04 3:54 
GeneralRe: Request help for 2 newbie questions Pin
Mazdak30-Jan-04 4:32
Mazdak30-Jan-04 4:32 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 4:36
bouli30-Jan-04 4:36 
GeneralRe: Request help for 2 newbie questions Pin
Mazdak30-Jan-04 4:45
Mazdak30-Jan-04 4:45 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 5:08
bouli30-Jan-04 5:08 
GeneralRe: Request help for 2 newbie questions Pin
Heath Stewart30-Jan-04 4:51
protectorHeath Stewart30-Jan-04 4:51 
GeneralRe: Request help for 2 newbie questions Pin
Mazdak30-Jan-04 5:00
Mazdak30-Jan-04 5:00 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 5:06
bouli30-Jan-04 5:06 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 5:10
bouli30-Jan-04 5:10 
GeneralRe: Request help for 2 newbie questions Pin
Heath Stewart30-Jan-04 5:24
protectorHeath Stewart30-Jan-04 5:24 
GeneralRe: Request help for 2 newbie questions Pin
bouli30-Jan-04 5:28
bouli30-Jan-04 5:28 
GeneralRe: Request help for 2 newbie questions Pin
TuringTest13-Feb-04 22:55
TuringTest13-Feb-04 22:55 
GeneralRe: Request help for 2 newbie questions Pin
Heath Stewart4-Feb-04 3:35
protectorHeath Stewart4-Feb-04 3: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 2:41
amadeonMk30-Jan-04 2:41 
GeneralRe: pdf printing Pin
Heath Stewart30-Jan-04 4:47
protectorHeath Stewart30-Jan-04 4:47 
GeneralRe: pdf printing Pin
amadeonMk30-Jan-04 8:02
amadeonMk30-Jan-04 8:02 
GeneralRe: pdf printing Pin
Heath Stewart30-Jan-04 9:39
protectorHeath Stewart30-Jan-04 9: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.