Page 1 of 1

Gibt es eine Methode zur Verwendung von base.base in einer Override-Methode? [Duplikat]

Posted: 27 Dec 2024, 12:41
by Anonymous
Das ist vielleicht eine schlechte Praxis, aber ich würde trotzdem gerne wissen, ob es möglich ist.

Code: Select all

public class BaseClass
{
protected virtual void createArrays(int vertexCount)
{
// do the actual work
}
}

public class A : BaseClass
{
protected override void createArrays(int vertexCount)
{
// Do something specific to A
base.createArrays(vertexCount);
}
}

public class B : A
{
protected override void createArrays(int vertexCount)
{
//Do something specific to B, but not to A
base.base.createArrays(vertexCount); // this is the part that doesn't work, I actually want to call the createArrays from the BaseClass
}
}
Es ist wahrscheinlich am besten, sowohl A als auch B von BaseClass zu erben, aber ich würde mich über einige Einblicke freuen