Say I have the following code:
class Parent
{
static string MyField = \"ParentField\";
public virtual string DoSomething()
{
return MyField
First, let me say that you really should just make MyField virtual and accept that you need to spawn an instance to get it. However, another way of "solving" the problem would be:
class Parent
{
public static string MyField = "ParentField";
protected virtual MyLocalField = MyField;
public virtual string DoSomething()
{
return MyLocalField;
}
}
class Child : Parent
{
public static new string MyField = "ChildField";
protected override MyLocalField = MyField;
}