Example

 using System; namespace Samples { public class EventArgsSample { public delegate void MouseClickEventHandler(object sender, MouseClickEventArgs args); public class MouseClickEventArgs: EventArgs { private string s; public MouseClickEventArgs(string s) { this.s = s; } public string Label {get {return s;}} } public class MyButton { private string label; public MyButton(string label) { this.label = label; } public event MouseClickEventHandler MouseClick; public void SimulateButtonClicked() { if(MouseClick != null) MouseClick(this, new MouseClickEventArgs(label)); } } public static void Main() { MyButton b = new MyButton("Click me"); b.MouseClick += new MouseClickEventHandler(ButtonClicked); b.SimulateButtonClicked(); } public static void ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.