回答編集履歴
1
インデントが変になったので直す
answer
CHANGED
@@ -4,13 +4,13 @@
|
|
4
4
|
```C#
|
5
5
|
public class A
|
6
6
|
{
|
7
|
-
|
7
|
+
protected virtual int x{ get{ return 1; } }
|
8
|
-
|
8
|
+
public void C(){ Console.WriteLine(x); }
|
9
9
|
}
|
10
10
|
|
11
11
|
public class B : A
|
12
12
|
{
|
13
|
-
|
13
|
+
protected override int x{ get{ return 2; } }
|
14
14
|
}
|
15
15
|
```
|
16
16
|
|
@@ -21,8 +21,8 @@
|
|
21
21
|
```C#
|
22
22
|
public class A
|
23
23
|
{
|
24
|
-
|
24
|
+
private static int TheStaticX = 1;
|
25
|
-
|
25
|
+
protected virtual int x{ get{ return TheStaticX; } }
|
26
|
-
|
26
|
+
public void C(){ Console.WriteLine(x); }
|
27
27
|
}
|
28
28
|
```
|