Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gtest-133.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 35162455e6a9b4f944b732da09eb910746d60752 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Not used -- ex-nullable-struct

// Converting a struct from S to S? creates a copy of the struct.
// Getting the struct out of the non-null value creates another copy.

using System;

struct S {
  private int x;
  public int X {
    get { return x; }
    set { this.x = value; }	// Cannot be used on non-variable ns.Value
  }
  public void Set(int x) {
    this.x = x;
  }
}

class MyTest {
  public static void Main(String[] args) {
    S s = new S();
    s.Set(11);
    Console.WriteLine("s.X = {0}", s.X);
    S? ns = s;
    Console.WriteLine("s.X = {0} ns.Value.X = {1}", s.X, ns.Value.X);
    ns.Value.Set(22);
    Console.WriteLine("s.X = {0} ns.Value.X = {1}", s.X, ns.Value.X);
    s.Set(33);
    Console.WriteLine("s.X = {0} ns.Value.X = {1}", s.X, ns.Value.X);
  }
}