summaryrefslogtreecommitdiff
path: root/mcs/tests/test-iter-02.cs
blob: 1be1bb28b489679d86f80af8f11621749a4331ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Compiler options: -langversion:default

using System;
using System.Collections;

class X {
	static int start, end;
	static int i;

	static IEnumerator GetRange ()
	{
		yield return 1;
		for (i = start; i < end; i++)
			yield return i;
		yield return 100;
	}

	public static int Main ()
	{
		start = 10;
		end = 30;

		int total = 0;
		
		IEnumerator e = GetRange ();
		while (e.MoveNext ()){
			Console.WriteLine ("Value=" + e.Current);
			total += (int) e.Current;
		}

		if (total != 491)
			return 1;
		return 0;
	}
}