Standing on the shoulders of giants. RSS 2.0
# Tuesday, November 20, 2007

Nice, you can use any IEnumerable as the source for you LINQ queries.

 

class Program {
    static void Main(string[] args) {

         var result = from x in GetSequence(12) where (x%2) == 0 select x;

         foreach (var x in result) {
             Console.WriteLine(x);
         }

        Console.ReadLine();

    }

    static IEnumerable<int> GetSequence(int max) {

        for (int i = 0; i < max; i++) yield return i;

    }
}
Tuesday, November 20, 2007 2:20:10 PM (W. Europe Standard Time, UTC+01:00)  #    Comments [0] - Trackback
Codesnippet
Comments are closed.
About
© Copyright 2008
Paul van Brenk
Sign In
newtelligence dasBlog 2.3.8275.16006
All Content © 2008, Paul van Brenk
DasBlog theme 'Business' created by Christoph De Baene (delarou)