public abstract class MyBase
{
public abstract bool MyProperty
{
get;
protected set;
}
}
public class MyClass : MyBase
{
public MyClass()
{
this.MyProperty = true;
}
public override bool MyProperty
{
get;
protected set;
}
}
The constructor MyClass() causes CA2214:
Do not call overridable methods in constructors.
This normally only shows if one calls a virtual method defined in the same class as the constructor. e.g. Accessing MyProperty
inside MyBase
's constructor. Here I am calling a non-virtual overridden implementation of an inherited abstract property inside the derived class' constructor.