Anonymous Methods in C# without parameters

This blog shows on how to use Anonymous methods with C# and without parameters.

using System.Windows.Forms;

public partial class Form1 : Form
{
public Form1()
{
Button btnHello = new Button();
btnHello.Text = "Hello";

btnHello.Click +=
delegate
{
MessageBox.Show("Hello");
};

Controls.Add(btnHello);
}
}

Ebook Download
View all
Learn
View all