C#C
C#2y ago
popcorn

Delegate function with params

Hello, is it possible to somehow have "named" parameters in the delegate function?
Right now I have:

public delegate bool ValidatorF<T>(params T[] args);

// Usage
public static class IntValidator
{
    public static ValidatorF<int> IsExact = args => args[0] == args[1];
}


But that way you have to remember that the first argument is the actual number and the second argument is the expected value for example (In this case it doesn't matter, but let's say we have 3+ args..)

My question is:
Is it possible to have the usage like this somehow? Or using some other approach?
 public static ValidatorF<int> IsExact = (val, expected)=> val == expected;
Was this page helpful?