Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Events2
- {
- delegate void YouSayYes();
- delegate void YouSayStop();
- class John{
- public event YouSayYes yousayyes;
- public event YouSayStop yousaystop;
- public void Sing()
- {
- Console.WriteLine("I say yes");
- if (yousayyes != null) yousayyes();
- Console.WriteLine("I say stop");
- if (yousayyes != null) yousaystop();
- }
- }
- class George{
- public void ISayNo(){
- Console.WriteLine("I say no !!");
- }
- public void ISayGo()
- {
- Console.WriteLine("I say Go Go gooooooooo !!");
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- George georgie = new George();
- John Lennon = new John();
- Lennon.yousayyes +=new YouSayYes( georgie.ISayNo );
- Lennon.yousaystop += new YouSayStop( georgie.ISayGo );
- Lennon.Sing();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement