Another nice addition to C# 2.0 is the yield keyword. Yield enables iterator blocks to provide values to an enumerated result, see the following example. // yield-example.cs using System; using System.Collections; public class List { public static IEnumerable Power(int number, int exponent) { int counter = 0; int result = 1; while(counter++ < exponent) { [...]
Archive for September 13th, 2005
C# 2.0 and the ‘yield’ keyword
Posted in Everything, Software Development, tagged C#, Code on September 13, 2005 | 6 Comments »
