The LBTT Spot
"Lifeline is focused on developing and marketing systems designed to assist in the early detection of breast and ovarian cancer."
C# Reference - C# Modifiers - event
View C# Source Code
Article Categories:
.Net Framework
.Net Framework 1.1
ADO.NET
ASP.NET
Assemblies
Asynchronous Methods
C#
Collections
Configuration
Delegates
Events
Pocket PC
Regular Expressions
Smart Devices
SQL Server
Visual C#
Visual Studio .NET
Visual Studio .NET 2003
Windows Forms
XML
C# .Net Fun Menu
View Current Page's ASP.NET Source Code
C# Reference
C# Study Flash Cards
Valuable Links
Contact Us
Site Map
Mike's Portfolio
C# Reference Search:
Full Text Search:
Articles by Author:
Mike G.
Code Examples (zipped):
MTGUpTime.zip
ThreadLockingE...
ThreadingExamp...
RemotingExampl...
ErrorProviderE...
DelegateExampl...
CustomArrayLis...
AsynchronousEx...
C# Reference
C# Modifiers
event
The event keyword is used to declare a delegate-type variable capable of raising events. When an event is raised through the event variable the target method is called through a predefined delegate. There are two components to an event: a delegate memeber and an event member.
// the delegate that will hold a pointer to the target method // once the event is raised public delegate void EventDelegate(); // the event variable based on the delegate above public event EventDelegate MyEvent; private void Form1_Load(object sender, System.EventArgs e) { // define what method will be called when the event is raised // by declaring an event handler this.MyEvent += new EventDelegate(EventDelegateTarget); } public void EventDelegateTarget() { // this method is called when MyEvent() is called } private void button1_Click(object sender, System.EventArgs e) { // raise the event MyEvent(); }