I'm debugging the following code:
class A
{
public virtual string X => "A";
}
class B : A
{
public bool OwnX { get; set; } = true;
public override string X
=> OwnX ? "B" : base.X; // (o)
}
class Program
{
static void Main() => Console.WriteLine(new B().X);
}
And I have a breakpoint on the line marked with (o)
. When the breakpoint hit, I'm trying to evaluate base.X
and getting its value "B"
:
The question is: why not "A"
?
As others have mentioned, this bug is well known.
You can trivially check that the actual value of base.X
is A, it is just the Expression Evaluator that returns the wrong result:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With