Anonymous Method

As the name suggests, an anonymous method is a method without a name. Anonymous methods in C# can be defined using the delegate keyword and can be assigned to a variable of delegate type.

Syntax:- 



delegate(argument)
{
}

Example:-

public delegate void Print(int value);

static void Main(string[] args) 
{
 int i = 10; Print prnt = delegate(int val)
 { 
 val += i;
 Console.WriteLine("Anonymous method: {0}", val); 
 };
prnt(100); 
}

No comments:

Post a Comment

Xamarin Android Project App

Xamarin Android Project App 1. Xamarin -- Make a CALCULATOR Android App   https://drive.google.com/open?id=0B8OPCXLrtKPmWC1FWWtFM2lraVk...