What do we mean by Anonymous Delegate?

 Posted by Rajesh_Kumar on 2/20/2014 | Category: C# Interview questions | Views: 2304 | Points: 40

Anonymous methods provide a technique to pass a code block as a delegate parameter.Anonymous methods are basically methods without a name,we can say it has just the body.
There is no return type in an anonymous method.It is inferred from the return statement inside the method body.

In other words,we can say that an anonymous method or delegate is an inline unnamed method in the code.It is created using the delegate keyword and doe not required name and return type.Hence we

can say,an anonymous method has only body without name,optional parameters and return type.
An anonymous method behaves like a regular method and allows us to write inline code in place of explicitly named methods.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response