Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-iter-03.cs
1 // Compiler options: -langversion:default
2
3 //
4 // Use
5
6 using System;
7 using System.Collections;
8
9 class X {
10         static IEnumerable GetIt (int [] args)
11         {
12                 foreach (int a in args)
13                         yield return a;
14         }
15
16         static IEnumerable GetMulti (int [,] args)
17         {
18                 foreach (int a in args)
19                         yield return a;
20         }
21         
22         public static int Main ()
23         {
24                 int total = 0;
25                 foreach (int i in GetIt (new int [] { 1, 2, 3})){
26                         Console.WriteLine ("Got: " + i);
27                         total += i;
28                 }
29
30                 if (total != 6)
31                         return 1;
32
33                 total = 0;
34                 foreach (int i in GetMulti (new int [,] { { 10, 20 }, { 30, 40}})){
35                         Console.WriteLine ("Got: " + i);
36                         total += i;
37                 }
38                 if (total != 100)
39                         return 2;
40                 
41                 return 0;
42         }
43 }