C# Syntax lambdas with curly braces
c#, lambda, syntax
Solution
Maybe this will make it clearer:
AddDelegate ad = (a, b) =>
{
return a + b;
};
These semicolons effectively are for different lines.
Problem
``` delegate int AddDelegate(int a, int b); AddDelegate ad = (a,b) => a+b; AddDelegate ad = (a, b) => { return a + b; }; ``` The two above versions of AddDelegate are equivalent. Syntactically, why is it necessary to have a semicolon before and after the `}` in the second AddDelegate? You can a compiler error `; expected` if either one is missing.