I have something like this:
class Node
{
protected Node Parent
{
get; private set;
}
}
class NodeDerived : Node
{
void SomeMethod()
{
Node parentIterator = this.Parent;
while (parentIterator != null)
{
// ... some logic
parentIterator = parentIterator.Parent; // Here's the error
}
}
}
But for some strange reason, I can't access parentIterator.Parent
property:
error CS1540: Cannot access protected member `Node.Parent' via a qualifier of type `Node'. The qualifier must be of type `NodeChild' or derived from it
Why is this happening? By the way, I also discovered that while I can access this.Parent
, I can't access ((Node) this).Parent
.