Multiple Callback Method Invocation C# with Example



Multiple Callback Method Invocation C# with Example

 using System;

namespace CSharpDelegate
{
	delegate void MyDelegate();	//Delegate Declaration
	
	class UsingDelegateWithMultipleCallbacks
	{
		static void Main()
		{
			MyDelegate callMethod = new MyDelegate(Display);
			callMethod += Hello;
			callMethod = callMethod + Hi;
			callMethod += Bye;
			
			callMethod();
		}
		
		public static void Display()
		{
			Console.WriteLine("This is Display() Method.");
		}
		
		public static void Hello()
		{
			Console.WriteLine("This is Hello() Method.");
		}
		
		public static void Hi()
		{
			Console.WriteLine("This is Hi() Method.");
		}
		
		public static void Bye()
		{
			Console.WriteLine("This is Bye Method.");
		}		
	}	
}
 

0 Comment's

Comment Form

Submit Comment