update readme (#21797)
[mono-project.git] / mcs / tests / dtest-optional-01.cs
blob09eacbefdf3613dfe06e82c6b61d0ef6ba464bbf
1 using System;
2 using System.Reflection;
3 using System.Runtime.InteropServices;
5 struct S
9 public class G<T>
12 public object M1 (T o = default (T))
14 return o;
17 public object M2 ([Optional] T o)
19 return o;
23 public class C
25 public static object Test ([Optional] dynamic a)
27 return a;
30 void TestS (S s = default (S))
34 object TestD (dynamic o = null)
36 return o;
39 public static int Main ()
41 if (Test () != Missing.Value)
42 return 1;
44 dynamic d = new C ();
45 d.TestS ();
47 if (d.TestD () != null)
48 return 2;
50 d = new G<string> ();
51 if (d.M1 () != null)
52 return 3;
54 if (d.M2 () != null)
55 return 4;
57 return 0;