[mono/tests] Fix out of tree build.
[mono-project.git] / mcs / tests / test-null-operator-04.cs
blobc28aa178ceb5520a50362fbcb39e5c8a26dbcf56
1 using System;
3 interface IFoo<T>
5 T Call ();
8 class C1
10 public void Foo<T> (IFoo<T> t) where T : class
12 t?.Call ();
13 var x = t?.Call ();
16 public void Foo2<T> (IFoo<T> t)
18 t?.Call ();
22 class C2<T> where T : class
24 C2<T> i;
25 T field;
27 public void Foo ()
29 var x = i?.field;
33 class Program
35 static void Test<T>(Func<T> func) where T : struct
37 var r = func?.Invoke ();
40 static void Test2<T>(Func<T> func)
42 func?.Invoke ();
45 static void Main()
47 new C1 ().Foo<Program> (null);
48 new C1 ().Foo2<Program> (null);
50 new C2<string> ().Foo ();
52 Test (() => 1);
53 Test (() => 2);