linux-packaging-mono/mcs/tests/gtest-variance-1.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

33 lines
456 B
C#

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;
}
}