top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Describe Anonymous functions in detail?

0 votes
61 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...