title: How to explicitly state the types when grouping in LINQ?
body: <p>I'm playing around with <em>GroupBy(...)</em> and I realize that, although working, I prefer not to use <em>var</em>. Call me anal but I like to know what type I have when I have it. (Of course, I'm not an ideologue and when the syntax is making ones eyes bleed, I do use <em>var</em>. Still, it's nice to know how to explicitize it, should ones urge emerge.)</p>
  
  <pre><code>var grouping = array.GroupBy(element =&gt; element.DayOfWeek);
  foreach (var group in grouping)
  {
    Console.WriteLine("Group " + group.Key);
    foreach (var value in group)
      Console.WriteLine(value.Start);
  }
  </code></pre>
  
  <p>According to the intellisense, I'm generating something of type <em>IGrouping</em> but when I tried to type that in explicitly, weird stuff happened. I've arrived at the following.</p>
  
  <pre><code>IEnumerable&lt;IGrouping&lt;DayOfWeek, TimeInfo&gt;&gt; grouping 
    = array.GroupBy(element =&gt; element.DayOfWeek);
  foreach (IGrouping&lt;DayOfWeek, TimeInfo&gt; group in grouping)
  {
    Console.WriteLine("Group " + group.Key);
    foreach (TimeInfo value in group)
      Console.WriteLine(value.Start);
  }
  </code></pre>
  
  <p>My question is twosome. Is the below the correct and most narrow scope for the produced result? If not, how can I tight it up additionally?</p>
  
  <p>If it is so, however, I'd like to know if there's a better way to approach the task. I only need to put my elements from the array into different bins with respect to day of the weeks (or any other condition in the actual production). I don't really need the key, just a way to make my 1D array into 2D array of arrays. Something like an opposite to <em>SelectMany</em>, so to speak. (No extensive answer needed - just a keyword to google away.)</p>