Free mag vol1 | Page 508

CHAPTER 12  LINQ TO OBJECTS Console.WriteLine("resultSet location: {0}", resultSet.GetType().Assembly.GetName().Name); } Assuming you have called this method within QueryOverStrings() directly after printing out the obtained subset, if you run the application, you will see the subset is really an instance of the generic OrderedEnumerable type (represented in terms of CIL code as OrderedEnumerable`2), which is an internal abstract type residing in the System.Core.dll assembly: ***** Info about your query ***** resultSet is of type: OrderedEnumerable`2 resultSet location: System.Core  Note Many of the types that represent a LINQ result are hidden by the Visual Studio object browser. These are low-level types not intended for direct use in your applications. LINQ and Implicitly Typed Local Variables While the current sample program makes it relatively easy to determine that the result set can be captured as an enumeration of string object (e.g., IEnumerable), I would guess that it is not clear that subset is really of type OrderedEnumerable. Given the fact that LINQ result sets can be represented using a good number of types in various LINQ-centric namespaces, it would be tedious to define the proper type to hold a result set, because in many cases the underlying type may not be obvious or even directly accessible from your code base (and as you will see, in some cases the type is generated at compile time). To further accentuate this point, consider the following additional helper method defined within the Program class (which I assume you will invoke from within the Main() method): static void QueryOverInts() { int[] numbers = {10, 20, 30, 40, 1, 2, 3, 8}; // Print only items less than 10. IEnumerable subset = from i in numbers where i < 10 select i; foreach (int i in subset) Console.WriteLine("Item: {0}", i); ReflectOverQueryResults(subset); } In this case, the subset variable is a compl etely different underlying type. This time, the type implementing the IEnumerable interface is a low-level class named WhereArrayIterator: 448