Rubyblood through your .NET veins with a vengeance
Posted by on June 28, 2008
In my last blog entry i totally neglected the fact that there are lamda expressions. This nice little C# 3.0 feature makes anonymous methods much more readable. With that in mind, we can make our Times method much nicer.
Example 1: Ruby style iterator with lambda expression
2.Times(
number => { Console.WriteLine("> " + number); }
);
Compared to the former syntax, it increases readability considerably.
Example 2: Ruby style iterator with bare delegate
2.Times(
delegate(int number)
{
Console.WriteLine("> " + number);
}
);
No comments registered
