以下示例中,我如何引用基类实例?如何引用基类实例?
public class A
{
public string test;
public A()
{
B b = new B();
test = "I am A class of test.";
}
public void hello()
{
MessageBox.Show("I am A class of hello.");
}
class B
{
public B()
{
//Here...
//How can I get A class of test and call A class of hello method
//base.test or base.hello() are not working.
}
}
}
如果这个例子在Java中,我可以使用A.this.test或A.this.hello(),但是在C#中我该怎么办?除了传递A到B的引用? – Jasper
你会怎么做?您在B类的实例中没有获得类A的实例。 – Carsten