Delegate Basics C# with Example



Delegate Basics C# with Example

 using System;

namespace CSharpDelegate
{
	delegate void MyDelegate();	//Delegate Declaration
	
	class UsingDelegate
	{
		static void Main()
		{
			MyDelegate callMethod = new MyDelegate(Display);	//Delegate Object Creation
			callMethod();		//Call Display() via callMethod Delegate
		}
		
		public static void Display()
		{
			Console.WriteLine("This method executed from the UsingDelegate Class.");
		}
	}	
}
 

0 Comment's

Comment Form

Submit Comment