Anonymous Method C# with Example



Anonymous Method C# with Example

 using System;

namespace CSharpDelegate
{
	delegate void MyDelegate();	//Delegate Declaration
	
	class AnonymousMethod
	{
		static void Main()
		{
			MyDelegate callMethod = new MyDelegate(delegate()
			{
				Console.WriteLine("This is Display() Method.");
			});
			callMethod += delegate() 
			{
				Console.WriteLine("This is Hello() Method.");
			};
			callMethod += delegate()
			{
				Console.WriteLine("This is Hi() Method.");
			};
			callMethod += delegate()
			{
				for(int i=0; i<10; i++)
				Console.WriteLine(i);
			};
			
			callMethod();
		}	
	}	
}
 

0 Comment's

Comment Form

Submit Comment