-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseAutoProperties.cs
More file actions
70 lines (61 loc) · 1.15 KB
/
Copy pathBaseAutoProperties.cs
File metadata and controls
70 lines (61 loc) · 1.15 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
public class CustomTypeBase {
public int A {
get;
set;
}
public virtual int B {
get;
set;
}
public CustomTypeBase () {
A = 4;
B = 8;
}
}
public class CustomType : CustomTypeBase {
new public int A {
get;
set;
}
public override int B {
get {
return base.B * 2;
}
set {
base.B = value / 2;
}
}
public int BaseA {
get {
return base.A;
}
set {
base.A = value;
}
}
public int BaseB {
get {
return base.B;
}
set {
base.B = value;
}
}
public CustomType () {
A = 8;
}
}
public static class Program {
public static void Main (string[] args) {
var instance = new CustomType();
Console.WriteLine(
"instance.A = {0}, instance.BaseA = {1}",
instance.A, instance.BaseA
);
Console.WriteLine(
"instance.B = {0}, instance.BaseB = {1}",
instance.B, instance.BaseB
);
}
}