AnonymousMethodsDemo.MainClass.Main C# (CSharp) Method

Main() static private method

static private Main ( string args ) : void
args string
return void
        static void Main(string[] args)
        {
            //create delegate instances using anonymous method
            NumberChanger nc = delegate (int x)
            {
                Console.WriteLine("Anonymous Method: {0}", x);
            };

            //calling the delegate using the anonymous method
            nc(10);

            //instantiating the delegate using the named methods
            nc = new NumberChanger(AddNum);

            //calling the delegate using the named methods
            nc(5);

            //instantiating the delegate using another named methods
            nc = new NumberChanger(MultNum);

            //calling the delegate using the named methods
            nc(2);
            Console.ReadKey();
        }