Using Get Invocation List Method C# with Example



Using Get Invocation List Method C# with Example

 using System;

namespace CSharpDelegate
{
	delegate void MyDelegate();	//Delegate Declaration
	
	class UsingGetInvocationListMethod
	{
		static void Main()
		{
			MyDelegate callMethod = new MyDelegate(Display);
			callMethod += Hello;
			callMethod = callMethod + Hi;
			callMethod += Bye;
			
			foreach(MyDelegate callback in callMethod.GetInvocationList())
			{
				Console.WriteLine("Method Name: " + callback.Method);
			}
		}
		
		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