action delegate with zero parameters

I. J. Kennedy picture I. J. Kennedy · Feb 27, 2009 · Viewed 17.3k times · Source

I see this line in many online examples of using the Action delegate:

public event Action MyEvent;

But when I try it in my own code, I get this error

Using the generic type 'System.Action' requires '1' type arguments

The documentation certainly describes a form of Action without any type parameter. What am I missing?

Answer

JaredPar picture JaredPar · Feb 27, 2009

Expanding on Andrews answer.

It's perfectly legal to use Action in a non-3.5 scenario. Simply define it yourself.

public delegate void Action();