C# Delegate & Event MCQs

Question 6: How would you declare an event for the following delegate?

	public delegate void ClickHandler();

Question 7: Which of the following is the built-in delegate function for handling events in .NET?

Question 8: What will be the output of the following program?

class Program
{
    static void Main(string[] args)
    {
        MyClass mc = new MyClass();

        mc.MyEvent += new EventHandler(mc.MyClassEventHandler);
        mc.MyEvent -= null;
    }
}

class MyClass
{
    public event EventHandler MyEvent
    {
        add
        {
            Console.Write("Add events here");
        }

        remove
        {
            Console.Write("Remove events here");
        }
    }

    public void MyClassEventHandler(object sender, EventArgs e)
    {
    }
}

Question 9: Events can also be declared static, virtual, sealed, and abstract.

Question 10: Which of the following can contain event declarations?