cleol
[mcs.git] / tests / gtest-linq-07.cs
blobed8ba5ac4392b984480728641b930d3cb6a1bd1b
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
7 class SelectMany
9 public static int Main ()
11 int[] a1 = new int [] { 0, 1 };
12 string[] a2 = new string [] { "10", "11" };
14 int id = 0;
16 // Explicitly typed
17 var e = from int i1 in a1
18 from string i2 in a2
19 select new { i1, i2 };
21 foreach (var item in e) {
22 Console.WriteLine (item);
24 if (item.i1 != id / 2)
25 return 1;
27 if (id % 2 == 0)
28 if (item.i2 != "10")
29 return 2;
31 ++id;
34 var e2 = from int i1 in a1
35 where i1 > 0
36 from string i2 in a2
37 from int i3 in a1
38 orderby i3
39 select new { pp = 9, i1, i3 };
41 id = 0;
42 foreach (var item in e2) {
43 Console.WriteLine (item);
45 if (item.i1 != 1)
46 return 3;
48 if (id / 2 != item.i3)
49 return 4;
50 ++id;
53 // Implicitly typed
54 var e3 = from i1 in a1
55 from i2 in a2
56 select new { i1, i2 };
58 id = 0;
59 foreach (var item in e3) {
60 Console.WriteLine (item);
62 if (item.i1 != id / 2)
63 return 1;
65 if (id % 2 == 0)
66 if (item.i2 != "10")
67 return 2;
69 ++id;
72 Console.WriteLine ("OK");
73 return 0;