Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-pattern-09.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 801469e32104894572df5f8054aae80cd05ba656 (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
using System.Collections.Generic;

class Expr
{
	public int Field;
}

static class X
{
	public static IEnumerable<int> Test (Expr expr)
	{
		object exprCur = expr;
		if (exprCur is Expr list) {
			yield return list.Field;
		}
	}

	public static IEnumerable<string> Test2 (int? expr)
	{
		int? exprCur = expr;
		while (exprCur != null) {
			if (exprCur is int list) {
				yield return list.ToString ();
			}
		}
	}	

	public static void Main ()
	{
		Test (null);
		Test2 (3);
	}
}