I have taken a look at this Question diference between delegate and action
and I'm still wondering why can I pass lambda expressions to methods that accept Action type parameters
whereas I can not pass lambda expressions to methods that accept Delegate type parameters
I have this Print method, I'm going to refer to it using action and Delegate
public static void Print()
{
Console.WriteLine("Printing ..");
}
I created these two methods which will invoke Print method as you can see the first one has Action type parameter and the second one has Delegate type Parameter these parameterss will refer to the method "Print"
public static void ActionParamMethod(Action DAction)
{
DAction();
}
public static void DelegateParamMethod(Delegate SomeDelegate)
{
}
I'm going to pass lambda expressions to these methods
public static void SomeHowMethod()
{
DelegateParamMethod(() => Print());
ActionParamMethod(() => Print());
}
when I try to pass lambda expression to the method which accept Delegate parameter I get this error
Cannot convert lambda expression to type 'System.Delegate' because it is not a delegate type
why it's not delegate type and Action is delegate type ?
why I can pass lambda expressions to methods that accept Action parameters, but I can't pass lambda expressions to methods that accept Delegate parameters?