using System;
public delegate void Message(string txt);
public class Messenger{
private string sender;
private Message message;
public Messenger(string sender){
this.sender = sender;
message = null;
}
public Messenger(string sender, Message aMessage){
this.sender = sender;
message = aMessage;
}
public void DoSend(){
message("Message from " + sender);
}
} | |
A delegate type named Message.
Can contain void methods that take a string parameter.
A simple class that encapsulates a sender
string and a Message delegate.
The encapsulated delegate
Constructor
Activation of the encapsulated delegate
|