25

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?

I. J. Kennedy
  • 23,413
  • 16
  • 60
  • 87

2 Answers2

37

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();
JaredPar
  • 703,665
  • 143
  • 1,211
  • 1,438
22

Make sure your application is referencing System.Core.

Edit - also make sure you are targeting .NET 3.5 as the System.Core.dll is part of that version.

Andrew Hare
  • 333,516
  • 69
  • 632
  • 626