// 1. first, define a parameter class
Public partial class sayeventargs: eventargs
{< br> Public string username;
Public string websiteurl;
}
//2. Define a delegate
Public Delegate VoidSayeventhandler (ObjectSender, sayeventargs E );
//3. Define an event
Public EventSayeventhandler sayevent;
//4. Events
Public VoidOnsayevent (sayeventargs E)
{
If(Sayevent! = Null)
{
Sayevent (This, E );
}
}
// 5. Passing parameter functions
Public Void Loginsite (string username, string websiteurl)
{
Sayeventargs E = New Sayeventargs ();
E. Username = Username;
E. websiteurl = Websiteurl;
Label1.text = E. Username + " <Br> " ;
Label1.text + = " Welcome to <a href = " + E. websiteurl + " > Xiaoxuan " ;
Onsayevent (E );
}
// 6. functions to be delegated
Public Void Saysomething ( Object Sender, sayeventargs E)
{
Label2.text = E. Username + " Note: <br> In this blog <a href = " + E. websiteurl + " > Xiaoxuan listening to xiaoxuan in the rain and night </a> level, it is not necessary for you to talk about wild things, but it will be used as a proof-of-concept in the future. OK? " ;
}
//7. Create a delegated instance
Sayevent+ = NewSayeventhandler (saysomething );
Loginsite ("Hazelnut","U/admin/index.html");