What is anonymous method

It is an inline unnamed method in the code.
It is created by the delegate keyword and doesn’t have return type.
or we can say, An anonymous method has no name, no optional parameters and no return type, it has only body.
Generally we use anonymous method in event handling.


class Program
//delegate for representing anonymous method
delegate int dele(int x, int y);
static void Main(string[] args)
//anonymous method using delegate keyword
dele ano = delegate(int x, int y) { return x * y; };
int result = ano(3, 3);



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s