Hi Guys
NP106 anonymous method
http://www.java2s.com/Code/CSharp/Language-Basics/delegate-anonymous.htm
Following program is in the above website. Why does it call anonymous method?
Anyone knows please explain the reason.
Thank you
using System;
using System.Threading;
public delegate void DelegateClass();
public class Starter
{
public static void
{
DelegateClass del = delegate
{
Console.WriteLine("Running anonymous method");
};
}
}
/*
Running anonymous method
Posted Jul 22, 2008, 9:39 AM
Hi Alan
Long time you haven’t been seen in the forum. Anyhow I am glad to see you again. Because you have helped me a lot. My computer was out of order during these days. That is why reply is late. Thank you for help.
AlanPosted Jul 14, 2008, 6:10 AM
It's called an anonymous method because it doesn't have a name like an ordinary method does.
Instead, the anonymous method is written 'inline' within another method and then assigned to a delegate variable so that it can be run by invoking the delegate.
In some other languages, anonymous methods are called 'closures' and in C# 3.0 they have been generalized into a more powerful form known as 'lambda expressions'.