I have this code:
s(x => x.Open());
s is a method which calls one parameter, which is perfectly fine, like so:
public void s(Action<p1> action) {}
Ignoring the naming conventions, if I make the method like the below:
public void s(Action<p1, p2> action) {}
How do I pass in more than one parameter? Out of interest, is there any way to use the params keyword with Action<>?
Also, I am using C# 4.0 so I would be interested to see how it can help me in an way.
Thanks
If you want to pass multiple parameters to a lambda expression in C# you need to enclose the parameters with parens. For example
s( (x,y) => x.Open(y) );
s((x, y) => ...);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With