top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Describe Anonymous functions in detail?

0 votes
327 views
Describe Anonymous functions in detail?
posted Nov 24, 2014 by Vinitha

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Anonymous means no name. An anonymous function is, an unnamed block of code that is passed to a delegate constructor. One advantage of using an anonymous function is that there is no need to declare a separate method whose only purpose is to be passed to a delegate. An anonymous method is created by following the keyword delegate with a block of code.
Example:

using System;

namespace Test
{
delegate void AnonymousDemo();
class Demo
{
static void Main()
{

AnonymousDemo DelObj = delegate
{
// This is the block of code passed to the delegate.

Console.WriteLine("Hello anonymous method");
}; // notice the semicolon
DelObj();
}
}
}
answer Nov 24, 2014 by Manikandan J
...