Sunday, 3 December 2017

C# Program to Create Anonymous Method


Code:

using System;
delegate void Print(string s);
class TestClass
{
    static void Main()
    {
        Print obj = delegate(string j)
        {
            System.Console.WriteLine(j);
        };
        obj("Delegate Using the Anonymous Method");
        obj = new Print(TestClass.named);
        obj("Delegate Using the Named Method");
        Console.Read();
    } 
    static void named(string k)
    {
        System.Console.WriteLine(k);
    }

}


Output:

Delegate Using the Anonymous Method
Delegate Using the Named Method



More C# Programs:
















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...