C# .net framework2.0 how to dynamically assign methods to an event

c++visual-studio-2008

VS2008, C#, .NET FRAMEWORK2.0

I want this: click button1, webbrowser1._DocumentCompleted() event revokes doA(); click button2, it revokes doB(); click button3, it revokes doC().

I know how to do it using JAVA and I guess C# has this mechanism too. Could anyone give me some idea or better, show me some example?

Best Solution

To add to these answers, you can also add an anonymous method to an event:

myButton.Click += (object sender, EventArgs e) => {
    MessageBox.Show("MASSIVE ERROR!");
};

What this means is that you can effectively call a method even if it does not match the appropriate event handler signature:

myButton.Click += (object sender, EventArgs e) => {
    DoA();
};

Or (without using a lamba expression):

myButton.Click += delegate(object sender, EventArgs e) {
    DoA();
};