|
Listing 14-38 extracted from chapter Unsafe code, exceptions, anonymous methods, iterators
Listing 14-37< > Listing 14-39
This listing can be compiled with the command line: csc.exe /target:exe Example_14_38.cs Errors: 0 Warnings: 0
Example_14_38.cs
public class Persons : System.Collections.IEnumerable {
public System.Collections.IEnumerator GetEnumerator() {
yield return "Michel";
yield return "Christine";
yield return "Mathieu";
yield return "Julien";
}
}
class Program {
static void Main() {
Persons arrPersons = new Persons();
foreach (string s in arrPersons)
System.Console.WriteLine(s);
}
}
Copyright Patrick Smacchia 2006 2007
|