[w32file] Move MonoIO.Find{First,Next,Close} to managed
[mono.git] / mcs / tests / gtest-linq-07.cs
1
2
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6
7 class SelectMany
8 {
9         public static int Main ()
10         {
11                 int[] a1 = new int [] { 0, 1 };
12                 string[] a2 = new string [] { "10", "11" };
13
14                 int id = 0;
15
16                 // Explicitly typed
17                 var e = from int i1 in a1
18                         from string i2 in a2
19                         select new { i1, i2 };
20                 
21                 foreach (var item in e) {
22                         Console.WriteLine (item);
23                         
24                         if (item.i1 != id / 2)
25                                 return 1;
26                         
27                         if (id % 2 == 0)
28                                 if (item.i2 != "10")
29                                         return 2;
30                                 
31                         ++id;
32                 }
33                 
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 };
40                 
41                 id = 0;
42                 foreach (var item in e2) {
43                         Console.WriteLine (item);
44                         
45                         if (item.i1 != 1)
46                                 return 3;
47                         
48                         if (id / 2 != item.i3)
49                                 return 4;
50                         ++id;
51                 }
52                 
53                 // Implicitly typed
54                 var e3 = from i1 in a1
55                         from i2 in a2
56                         select new { i1, i2 };
57                 
58                 id = 0;
59                 foreach (var item in e3) {
60                         Console.WriteLine (item);
61                         
62                         if (item.i1 != id / 2)
63                                 return 1;
64                         
65                         if (id % 2 == 0)
66                                 if (item.i2 != "10")
67                                         return 2;
68                                 
69                         ++id;
70                 }
71
72                 Console.WriteLine ("OK");
73                 return 0;
74         }
75 }
76