blog vipa
mój dzień to 3 filiżanki kawy

blog vipa

Cztery godziny z życia

październik 25th, 2008 . by vip

Uwielbiam coś pisać (tu: wywoływanie i przechwytywanie zdarzeń), i nagle, zupełnie przypadkiem, dostać wyjątkiem w twarz. A potem szukać, debugować, przez kilka godzin, żeby się na końcu okazało, że przecież wszystko jest napisane w dokumentacji!

“Once a class has declared an event, it can treat that event just like a field of the indicated delegate type. The field will either be null, if no client has hooked up a delegate to the event, or else it refers to a delegate that should be called when the event is invoked. Thus, invoking an event is generally done by first checking for null and then calling the event.”¹

C#:
  1. if (Changed != null)
  2.       Changed(this, e);

Tak, zabrakło mi if()…

PS. Dla mnie to jest tak trochę głupie, jak if(na obiekcie) przed wykonaniem delete tegoż (w C++).



Leave a Reply