" requires arguments of type "1" I am transferring working code from .N...">

Delegation of action in .NET2. Using the generic type "System.Action <T>" requires arguments of type "1"

I am transferring working code from .NET4 to .NET2 (WinCE device).

Using Action without arguments and returning a value is not allowed in .NET2

Compilation error in line 5 below: Using the generic type "System.Action" requires arguments of type "1"

Workarounds?

//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
+5
source share
1 answer

Indeed, it Actionwas added in .NET 3.5.

However, this Actionis the usual type of delegation, so you can just flip it, for example:

public delegate void Action();
+10
source

All Articles