Check out how convoluted this Hello World is using an anonymous method in C# 2.0:
using System;
using System.Collections.Generic;
using System.Text;
namespace HelloWorld
{
///
/// Declare a delegate that will do something with a string.
///
public delegate void AcceptString(string s);
public class Program
{
static void Main(string[] args)
{
//create the delegate using an anonymous method
//in other words, this object is really a method
AcceptString writeConsole = delegate(string s)
{
Console.WriteLine(s);
};
//call the object/method
writeConsole("Hello World!");
}
}
}
No comments:
Post a Comment