Ads Top

Anonymous function in C#

Anonymous function. Anonymous functions include lambda expressions. You can pass a lambda expression as the implementation of the delegate. You can construct the UppercaseDelegate by specifying a lambda expression inside the constructor itself.
Note:This is functionally equivalent to using a static method with the same return value and argument.

        Anonymous Functions

C# program that uses lambda expression, delegate

using System;

class Program
{
    // ...
    // ... (Paste other methods here)
    // ...

    static void Main()
    {
        WriteOutput("perls", new UppercaseDelegate(x => x.ToUpper()));
    }
}

Output

PERLS
Powered by Blogger.