0
我以爲它會調用派生類函數,因爲教室將給其自身功能的重要性,但它在調用基類的功能,請大家指正...請指正與OOP繼承
class Baseclass
{
public void fun()
{
Console.Write("Base class" + " ");
}
}
class Derived1 : Baseclass
{
new void fun()
{
Console.Write("Derived1 class" + " ");
}
}
class Derived2 : Derived1
{
new void fun()
{
Console.Write("Derived2 class" + " ");
}
}
class test
{
static void Main(string[] args)
{
Derived2 d = new Derived2();
d.fun();
}
}
你可能要一個語言標記添加到您的問題:) – geisterfurz007
@ geisterfurz007 C# – suri