I was looking around for an answer to this but couldn’t find anything related. I have learnt to use Action.Invoke() when using an Action, but do you actually need to use .Invoke?
Say I have this Action:
Action<int> action = x =>
{
Console.WriteLine(x + 1);
};
Do I use:
action.Invoke(2);
or
action(2);
What’s the difference?
Thanks
Its the same thing,
action(2);basically callsaction.Invoke(2);The compiler converts
action(2)intoaction.Invoke(2);From a post from Jon Skeet: