2004-06-08 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / tests / 2test-3.cs
1 //
2 // Use
3
4 using System;
5 using System.Collections;
6
7 class X {
8         static IEnumerable GetIt (int [] args)
9         {
10                 foreach (int a in args)
11                         yield return a;
12         }
13
14         static IEnumerable GetMulti (int [,] args)
15         {
16                 foreach (int a in args)
17                         yield return a;
18         }
19         
20         static int Main ()
21         {
22                 int total = 0;
23                 foreach (int i in GetIt (new int [] { 1, 2, 3})){
24                         Console.WriteLine ("Got: " + i);
25                         total += i;
26                 }
27
28                 if (total != 6)
29                         return 1;
30
31                 total = 0;
32                 foreach (int i in GetMulti (new int [,] { { 10, 20 }, { 30, 40}})){
33                         Console.WriteLine ("Got: " + i);
34                         total += i;
35                 }
36                 if (total != 100)
37                         return 2;
38                 
39                 return 0;
40         }
41 }