Everytime I need a very small Method that only uses its parameters…
Should I use declare a Delegate or a Method?
Eg: Multiply three numbers
Func<int, int, int, int> Multiply = (a,b,c) => a*b*c;
and
int Multiply(int a, int b, int c)
{
return a*b*c;
}
Edit:
I want to focus this question in terms of eficiency when compiling, and readability.
I wouldn’t declare a delegate rather than a method just for the sake of it. If you’re just to call this directly from other code in your class, a method is more idiomatic. If it doesn’t need to use any instance variables, you may want to make it a static method to make that clear.
On the other hand, if you only ever need to use it as a delegate, use a lambda expression to create that delegate (as per your first example).
If you want to call it directly and use it as a delegate, you can use a method group conversion to create a delegate easily: