IEnumerable with a foreach loop : IEnumerable « Class Interface « C# / C Sharp






IEnumerable with a foreach loop

 

using System;
using System.Collections.Generic;
using System.Linq;
public class MainClass {
    public static void Main() {

        IEnumerable<char> query = "Not what you might expect";

        foreach (char vowel in "aeiou")
            query = query.Where(c => c != vowel);

        foreach (char c in query) Console.Write(c); 
    }
}

 








Related examples in the same category

1.yield return
2.return IEnumerable
3.Return IEnumerable by yield
4.iterates a collection forward and reverse
5.Extends IEnumerable
6.Enumerator Example (Versioned Collection)
7.Tree Enumerator