Snippet: private event with EventHandler<T>

property value
IDE Visual Studio
Language C#
Title private event with EventHandler<T>
Shortcut pet
Description private event declaration with EventHandler<T>
Snippet Types Expansion
Namespaces System

Placeholders

Identifier Tooltip Default Value Editable Function Type Name
eventArgs EventArgs type name EventArgs yes
name Event name EventName yes

Code

private event EventHandler<EventArgs> EventName;

protected virtual void OnEventName(EventArgs e) {
	EventHandler<EventArgs> handler = EventName;
	if (handler != null) {
		handler(this, e);
	}
}