Skip to content

Instantly share code, notes, and snippets.

@virtualstaticvoid
Created May 12, 2009 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virtualstaticvoid/110629 to your computer and use it in GitHub Desktop.
Save virtualstaticvoid/110629 to your computer and use it in GitHub Desktop.
Generic event firing in C#
using System;
namespace MyNamespace
{
public static class MyExtensions
{
public static void Fire<TSender, TEventArgs>(this EventHandler<TSender, TEventArgs> myEvent, TSender sender, TEventArgs e)
where T EventArgs: EventArgs
{
if(myEvent != null)
myEvent(sender, e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment