.Net > Random > Beginner Next/Skip this question

What would be the output of following code snippet?

using System;

class MyClass
{
    public delegate void MyDelegate(string str);

    public void ExecuteDelegate(MyDelegate myDelegate)
    {
        if (myDelegate != null)
        {
            myDelegate("NotNull");
        }
        else
        {
            Print("Null");
        }
    }

    private void Print(string str)
    {
        Console.WriteLine(str);
    }
}

class Program
{
    static void Print(string str)
    {
        Console.WriteLine(str);
    }
    static void Main(string[] args)
    {
        MyClass myClass = new MyClass();
        MyClass.MyDelegate myDelegate = new MyClass.MyDelegate(Print);
        myClass.ExecuteDelegate(myDelegate);
        myDelegate = null;
        myClass.ExecuteDelegate(myDelegate);
        Console.ReadLine();
    }
}
Answers :
Explaination :
social share share on facebook share on twitter share on google plus share on linkedin
Add Comments :

Login

Register

Next Question