How to override a getter-only property with a setter in C#?
Be careful with your solution as it hides the original intent for A and B. That being said, your solution does work, even when casting to base classes.
Example:
D d = new D();
d.X = 2;
B b = d as B;
Assert.AreEqual(2, b.X);
If the base classes can be modified, I recommend using reflection.