In c++ I would do
class A
{
public:
virtual void stuff()
{
//something
}
};
class B : public A
public:
virtua开发者_开发百科l void stuff()
{
//something2
A::stuff() //something
}
};
How would I do this in C#? I've tried
public void stuff()
{
//something2
A.stuff(); //something
}
but that doesn't work
base
is the keyword for referencing your superclass in C#. Use:
base.stuff();
Use base
. Like base.stuff();
Just to add to the answer above, base.stuff() works, unless it's the constructor you're trying to call in which case it is called as:
class A
{
public:
public A(){}
};
class B : A
{
public B() : base()
{
}
};
精彩评论