From the course: .NET Essentials: Working with LINQ
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Solution: Group results by color values - .NET Tutorial
From the course: .NET Essentials: Working with LINQ
Solution: Group results by color values
(upbeat music) - This is the last code challenge in the course. I hope you had fun working on it. These are my results, your solution could be different. The first challenge was to group by RedPercent and to round it to two decimal places. So I use my group and by, and then my expression is shown here. So take the RedPercent value, call Math.Round on that and round to two decimal places, looks like this. So the first group is 0.55, the next group is 0.7, 0.8 and so on. For the next example, this is the challenge to do multiple criteria for the key, here's what I came up with. I used an anonymous type in the by part, for this is for the criteria. So I used an anonymous type and said group by BlueValue and by GreenValue. So this is the blue, GreenValue. So this unique pair of 0, 0, that's the first group, there's four items in there. The next group is 34, 34, there's one item in there. Next group is 92, 92, and…
Contents
-
-
-
-
-
-
-
-
-
-
-
The GroupBy method2m 27s
-
(Locked)
GroupBy query expression1m 53s
-
(Locked)
GroupBy with ElementSelector2m 36s
-
(Locked)
GroupBy with ResultSelector2m 29s
-
(Locked)
Iterate over groups1m 44s
-
(Locked)
Combine two sequences3m 47s
-
(Locked)
Flatten sequence with SelectMany2m 15s
-
(Locked)
Challenge: Group results by color values2m 30s
-
(Locked)
Solution: Group results by color values1m 35s
-
-
-
-
-
-
-