4 using System
.Collections
.Generic
;
9 public static int Main ()
11 int[] int_array
= new int [] { 0, 1, 2, 3, 4 }
;
13 IEnumerable
<IGrouping
<int, int>> e
;
15 // group by i % 2 from 1
16 e
= from int i
in int_array
group 1 by i
% 2;
18 List
<IGrouping
<int, int>> output
= e
.ToList ();
19 if (output
.Count
!= 2)
22 foreach (IGrouping
<int, int> ig
in e
) {
23 Console
.WriteLine (ig
.Key
);
24 foreach (int value in ig
) {
25 Console
.WriteLine ("\t" + value);
31 // group by i % 2 from i
32 e
= from int i
in int_array
group i by i
% 2;
35 if (output
.Count
!= 2)
38 int[] results_a
= new int[] { 0, 2, 4, 1, 3 }
;
41 foreach (IGrouping
<int, int> ig
in e
) {
42 Console
.WriteLine (ig
.Key
);
43 foreach (int value in ig
) {
44 Console
.WriteLine ("\t" + value);
45 if (value != results_a
[pos
++])
50 Console
.WriteLine ("OK");