Reputation: 6626
I'm porting working code from .NET4 to .NET2 (a WinCE device).
The usage of Action taking no arguments and returning no value isn't allowed in .NET2
compile error on line 5 below: Using the generic type 'System.Action' requires '1' type arguments
Workaround thoughts?
//first state is the default for the system
public enum States { EnterVoucherCode, EnterTotalSale, ProcessVoucher };
public enum Events { PressNext, PressRedeem, ProcessSuccess, ProcessFail, PressBackToVoucherCode };
public States State { get; set; }
private Action[,] fsm; //Fails to compile here
public FiniteStateMachine()
{
//array of action delegates
fsm = new Action[3, 5] {
//PressNext, PressRedeem, ProcessSuccess, ProcessFail, PressBackToVoucherCode
Upvotes: 5
Views: 5137
Reputation: 36852
Indeed, the non-generic Action
was added in .NET 3.5.
However, Action
is just an ordinary delegate type, so you could simply roll your own, like so:
public delegate void Action();
Upvotes: 12