OK so I admit right off the top that this is a bit screwy … but it does serve a logical purpose. I’m using C# for a current project and I’m trying to find a way to override
class BaseClass
{
public virtual string Method()
{
return string.Empty;
}
}
abstract class BaseClass : BaseClass where T : BaseClass
{
protected static string[] strings;
public override string Method()
{
return string.Join(" ", strings);
}
}
class Subclass1 : BaseClass
{
static Subclass1()
{
strings = new[] { "class1value1", "class1value2", "class1value3" };
}
}
class Subclass2 : BaseClass
{
static Subclass2()
{
strings = new[] { "class2value1", "class2value2", "class2value3" };
}
}
The important part is the generic parameter T which basically functions as an index to the string arrays.