2 // Test that the foreach statement generated by mcs invokes the Dispose()
3 // method even if the enumerator class returned by GetEnumerator () does not
4 // implement IDisposable.
9 public class Enumerator
{
13 public Enumerator () {
17 public bool MoveNext () {
18 return (counter
-- > 0);
28 class RealEnumerator
: Enumerator
, IDisposable
{
32 public RealEnumerator (Coll c
) {
36 public void Dispose () {
45 public Enumerator
GetEnumerator () {
46 return new RealEnumerator (this);
52 public static int Main(String
[] args
)
54 Coll coll
= new Coll ();
55 foreach (char c
in coll
) {
57 return (coll
.disposed
? 0 : 1);