What is Anonymous function?

Technology CommunityCategory: LINQWhat is Anonymous function?
VietMX Staff asked 3 years ago

An Anonymous function is a special function which does not have any name. We just define their parameters and define the code into the curly braces.

Consider:

delegate int func(int a, int b);
static void Main(string[] args)
{
    func f1 = delegate(int a, int b)
    {
        return a + b;
    };
 
    Console.WriteLine(f1(1, 2));
}