2 // Tests the foreach on strings, and tests the implicit use of foreach
3 // to pull the enumerator from the class and identify the pattern to be called
6 using System
.Collections
;
11 public bool MoveNext ()
17 public object Current
{
26 static string [] a
= {
30 public Y
GetEnumerator ()
35 public static int Main ()
42 foreach (string s
in a
){
45 if (total
!= "onetwothree")
54 foreach (object o
in x
){
61 // Looking for GetEnumerator on interfaces test
63 Hashtable xx
= new Hashtable ();
67 IDictionary vars
= xx
;
69 foreach (string name
in vars
.Keys
){
70 total2
= total2
+ name
;
73 if ((total2
!= "AB") && (total2
!= "BA"))
76 ArrayList list
= new ArrayList ();
83 // This test will make sure that `break' inside foreach will
84 // actually use a `leave' opcode instead of a `br' opcode
86 foreach (string s
in list
){
95 Console
.WriteLine ("test passes");