action delegate with zero parameters
17,658
Solution 1
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.
Solution 2
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();
Related videos on Youtube
Comments
-
I. J. Kennedy about 2 years
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?
-
Meydjer Luzzoli about 15 yearsNot an answer to the question, but you shouldn't use an Action for an event. Use either EventHandler or EventHandler<T> as the delegate for events.
-
I. J. Kennedy over 12 years@GregBeech, thanks for the tip, but what is the reason not to use Action here?
-
-
I. J. Kennedy about 15 yearsThanks! I did not have a System.Core reference. Even knowing the answer, I still could not find it in the docs.
-
AC88 about 15 yearsUnless you are passing it to someone elses library, that is using System.Core's Action...
-
JaredPar about 15 years@Simon, in that case you must already be using 3.5 (directly or indirectly) so it's not an issue.