This article introduces the EventHandler in C # through case examples, and the friends you need refer to it.
Needless to say, the detailed details are as follows:
Here defines a water tank class public class water tank { //This is the water tank's discharge operation public Void Discharge () {} //This is the property of the water tank public double volume; This is the water tank empty event public event EventHandler tank empty; This defines a water refill class public class water refill {public void plus water (Object sender, EventArgs e) { //Add water to the water tank that needs to be added }} public Class user{public User () { //instantiate tank type water tank 1 = new water tank (); Example of water-adding device 1 = new water-adding device (); Water Refill register Tank empty event water tank 1. Water tank Empty + = new EventHandler (water refill 1. Add water); } Private water-adding water device 1; Private tank water tank 1;}
--------------------------------------------------------------------------------------------
The most classic explanation for C # delegates:
Example:
This. Activated + = new EventHandler (form1_activated);
This is the principle of a delegate.
This. Activated= you have finished your meal; Form1_activated= shout Me a voice
The meaning of this sentence is to put these two things together, meaning that you eat the meal after the call me. I entrust you to finish dinner, shout me. So I don't have to take a moment to see if you have finished eating, have entrusted you.
"Recommended"
1. Special recommendation : "PHP Programmer Toolkit" V0.1 version download
2. asp free Video Tutorial
3. Eon the ASP Basic video tutorial