public static class LoopingExtensions
{
public static void Times(this int upperBound, Action action)
{
for (int index = 0; index < upperBound; index++)
action.Invoke(index);
}
用法:
public static void TestRubyLoop(){
50.Times(i => {
Console.WriteLine("We Built This City...");
Console.WriteLine("We Built This City...");
Console.WriteLine("On Rock And Roll");
}
}
沒有留言:
發佈留言