summaryrefslogtreecommitdiff
path: root/mcs/tests/gtest-variance-1.cs
blob: 036d38fbdef6c6065b70a320689d377eed515982 (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
interface IFoo<out T>
{
	T Bar { get; }
}

class Foo : IFoo<string>
{
	readonly string bar;
	public Foo (string bar)
	{
		this.bar = bar;
	}
	public string Bar { get { return bar; } }
}

public class Test
{
	public static int Main ()
	{
		string bar = "Who is John Galt?";
		IFoo<string> foo = new Foo(bar);
		IFoo<object> foo2 = foo;
		if (!foo2.Bar.Equals (bar))
			return 1;

		foo2 = new Foo(bar);
		if (foo2.Bar != bar)
			return 2;

		return 0;
	}
}