delegates/4/Messenger.cs - Install and UnInstall message methods in the Messenger class. | Lecture 6 - slide 9 : 20 Program 1 |
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 InstallMessage(Message mes){ this.message += mes; } public void UnInstallMessage(Message mes){ this.message -= mes; } public void DoSend(){ message("Message from " + sender); } }