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 |