[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / tests / test-null-operator-05.cs
blobecbc6019059105b87a997e1ee08f830545102d92
1 using System;
3 class CI
5 public string this [string i] { set { } get { return ""; } }
6 public int? this [int i] { set { } get { return 1; } }
9 class C
11 static int TestArrayAccess ()
13 byte[] arr = null;
14 var v = arr? [0];
15 if (v != null)
16 return 1;
18 long?[] ar2 = null;
19 var v2 = ar2? [-1];
20 if (v2 != null)
21 return 2;
23 var v3 = arr? [0].GetHashCode () ?? 724;
24 if (v3 != 724)
25 return 3;
27 string[] ar3 = null;
28 var v4 = ar3?[0].Length;
29 if (v4 != null)
30 return 4;
32 // TODO: Disabled for now?
33 // arr? [0] += 2;
34 return 0;
37 static int TestIndexerAccess ()
39 CI ci = null;
40 var v = ci? ["x"];
41 if (v != null)
42 return 1;
44 var v2 = ci? [0];
45 if (v2 != null)
46 return 2;
48 var v3 = ci? [0].GetHashCode () ?? 724;
49 if (v3 != 724)
50 return 3;
52 // TODO: Disabled for now?
53 // ci? [0] += 3;
54 return 0;
57 static int Main ()
59 int res;
60 res = TestArrayAccess ();
61 if (res != 0)
62 return 10 + res;
64 res = TestIndexerAccess ();
65 if (res != 0)
66 return 20 + res;
68 Console.WriteLine ("ok");
69 return 0;