How do you name delegates, events and instance of events?
I use this:
delegate void OnSomethingHandler(); event OnSomethingHandler onSomething;
Is this an accepted way? Notice lower and upper cases
Where do you place delegates and events?
I usually put delegates in an a namespace best reflecting them:
mynamespace.Def.SomethingLike { } mynamespace.Def.SomethingElseLike { }
Where do you define events?
I usually place them into the class that uses them.
I notice that a lot of people define delegates and events in the same class. How common is that?
Everything you have looks pretty standard – the only thing I would change is that the event name would be
Somethingrather thanonSomething. Following Microsofts convention you would end up with something more like this:And as a cool trick you can add an empty delegate to your
Somethingevent so that you don’t have to check the event for null before you raise it: