Say I have the following code:
class Parent
{
static string MyField = \"ParentField\";
public virtual string DoSomething()
{
return MyField
The only way is overriding DoSomething
method or else it is not possible. The DoSomething
in Parent
method essentially translates to:
public virtual string DoSomething()
{
return Parent.MyField;
}
When you "new
" a property, it only applies to that type - in this case Child
class. If the property is accessed via the 'Parent', it will always return the original property.