Merge pull request #5675 from mono/glib-debug-symbols
[mono.git] / mcs / tests / gtest-539.cs
1 using System;
2
3 struct S
4 {
5         public int ID { get; set; }
6 }
7
8 class C
9 {
10         public readonly int ID;
11
12         private C (int id)
13         {
14                 ID = id;
15         }
16
17         public static explicit operator C (S x)
18         {
19                 throw new ApplicationException ("wrong conversion");
20         }
21
22         public static explicit operator C (S? x)
23         {
24                 return new C (x.HasValue ? x.Value.ID : 5);
25         }
26 }
27
28 public class Test
29 {
30         public static int Main ()
31         {
32                 S? s = null;
33                 C c = (C) s;
34
35                 if (c.ID != 5)
36                         return 1;
37
38                 s = new S () { ID = 10 };
39                 c = (C) s;
40
41                 if (c.ID != 10)
42                         return 2;
43
44                 return 0;
45         }
46 }