tl:
8 12 48
t2:
8 12 48
t3:
4 4 8
base. base, . , base , . . base (). , , .
, . . C# , , , . , new, . ,
, , new, .
.
// .
Using System;
class {
public int i = 0;
}
// . j
class : A { *
new int i; // i public (int b) {
i = ; // i
}
public void Show() {
Console.WriteLine(" i : " + i);
}
}
class NameHiding { static void Main() {
ob = new (2);
Ob.Show();
}
}
new .
new int i; // i
, , , i i . new , .
.
i : 2
i, i . Show () i, , , .
base
|
|
base, this, , , . :
base .
. base , . .
// base // , .
Using System;
class {
public int i = 0;
}
// , class : {
new int i; // i
public (int a, int b) {
base.i = ; //
i = ; // i
}
public void Show() {
// i .
Console.WriteLine(" i : " + base.i);
// i .
Console.WriteLine(" i : " + i);
}
}
class UncoverName { static void Main() {
ob = new (1, 2); ob.Show ();
}
}