* TaskLoggingHelper.cs (LogErrorFromException): Add missing overload.
[mcs.git] / tests / test-36.cs
blobc436c318e776c1fd207e7854a5d78b96fac5428b
1 //
2 // This program excercises invoking foreach on structures
3 // that implement GetEnumerator
4 //
6 using System;
7 using System.Collections;
8 struct X {
9 int [] a;
11 public IEnumerator GetEnumerator ()
13 a = new int [3] { 1, 2, 3};
14 return a.GetEnumerator ();
18 class Y {
19 static X x;
21 static int Main ()
23 int total = 0;
24 x = new X ();
26 foreach (object a in x){
27 total += (int) a;
30 if (total != 6)
31 return 1;
33 total = 0;
35 foreach (object a in new X ()){
36 total += (int) a;
38 if (total != 6)
39 return 3;
41 total = 0;
44 // implicit block
46 foreach (object a in x)
47 total += (int) a;
48 if (total != 6)
49 return 2;
51 return 0;