[w32file] Move MonoIO.Find{First,Next,Close} to managed
[mono.git] / mcs / tests / test-null-operator-04.cs
1 using System;
2
3 interface IFoo<T>
4 {
5         T Call ();
6 }
7
8 class C1
9 {
10         public void Foo<T> (IFoo<T> t) where T : class
11         {
12                 t?.Call ();
13                 var x = t?.Call ();
14         }
15
16         public void Foo2<T> (IFoo<T> t)
17         {
18                 t?.Call ();
19         }       
20 }
21
22 class C2<T> where T : class
23 {
24         C2<T> i;
25         T field;
26
27         public void Foo ()
28         {
29                 var x = i?.field;
30         }
31 }
32
33 class Program
34 {
35         static void Test<T>(Func<T> func) where T : struct
36         {
37                 var r = func?.Invoke ();
38         }
39
40         static void Test2<T>(Func<T> func)
41         {
42                 func?.Invoke ();
43         }
44
45         static void Main()
46         {
47                 new C1 ().Foo<Program> (null);
48                 new C1 ().Foo2<Program> (null);
49
50                 new C2<string> ().Foo ();
51
52                 Test (() => 1);
53                 Test (() => 2);
54         }
55 }