Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / gtest-133.cs
1 // Not used -- ex-nullable-struct
2
3 // Converting a struct from S to S? creates a copy of the struct.
4 // Getting the struct out of the non-null value creates another copy.
5
6 using System;
7
8 struct S {
9   private int x;
10   public int X {
11     get { return x; }
12     set { this.x = value; }     // Cannot be used on non-variable ns.Value
13   }
14   public void Set(int x) {
15     this.x = x;
16   }
17 }
18
19 class MyTest {
20   public static void Main(String[] args) {
21     S s = new S();
22     s.Set(11);
23     Console.WriteLine("s.X = {0}", s.X);
24     S? ns = s;
25     Console.WriteLine("s.X = {0} ns.Value.X = {1}", s.X, ns.Value.X);
26     ns.Value.Set(22);
27     Console.WriteLine("s.X = {0} ns.Value.X = {1}", s.X, ns.Value.X);
28     s.Set(33);
29     Console.WriteLine("s.X = {0} ns.Value.X = {1}", s.X, ns.Value.X);
30   }
31 }