F
Fons
In the fragment below, I can use 'base' in getbaseval() to get the
hidden value of 'a' in the role of a member of class A. Is it possible to
access this value directly, something like the (incorrect) attempt I made?
class A {
public int a=1;}
class B:A {
new public int a=2;
public int getval(){return a;}
public int getbaseval() {return base.a;}}
class Demo {
public static void Main(){
B ob = new B();
Console.WriteLine(ob.getval());
Console.WriteLine(ob.getbaseval());
Console.WriteLine(ob.a);
//Console.WriteLine(ob.base.a);
}}
hidden value of 'a' in the role of a member of class A. Is it possible to
access this value directly, something like the (incorrect) attempt I made?
class A {
public int a=1;}
class B:A {
new public int a=2;
public int getval(){return a;}
public int getbaseval() {return base.a;}}
class Demo {
public static void Main(){
B ob = new B();
Console.WriteLine(ob.getval());
Console.WriteLine(ob.getbaseval());
Console.WriteLine(ob.a);
//Console.WriteLine(ob.base.a);
}}