I play with GroupBy (...) and I understand that although I work, I prefer not to use var. Call me anal, but I like to know what type I have when I have. (Of course, I'm not an ideologist, and when the syntax makes me lose my eyes, I use var. Nevertheless, it's nice to know how to draw it if they want to appear.)
var grouping = array.GroupBy(element => element.DayOfWeek);
foreach (var group in grouping)
{
Console.WriteLine("Group " + group.Key);
foreach (var value in group)
Console.WriteLine(value.Start);
}
According to intellisense, I am generating something like IGrouping, but when I tried to enter it explicitly, something strange happened. I came to the next.
IEnumerable<IGrouping<DayOfWeek, TimeInfo>> grouping
= array.GroupBy(element => element.DayOfWeek);
foreach (IGrouping<DayOfWeek, TimeInfo> group in grouping)
{
Console.WriteLine("Group " + group.Key);
foreach (TimeInfo value in group)
Console.WriteLine(value.Start);
}
My question is twofold. Is the correct and narrowest area below the result? If not, how can I fix it additionally?
, , . ( ). , 1D- 2D . - SelectMany, . ( - google.)