.NET FAQs Unleashed!
 
    
    

Can a method in C# be created without a name? If yes, how?

Yes, this is possible using anonymous methods. These methods are not directly declared; rather they are hooked up to events on the fly.

 

Example (C#):

 

btnSubmit.Click +=
delegate
{
                    MessageBox.Show("dotnetuncle makes it easy");
};
Controls.Add(btnSubmit);


More Interview Questions...