Even though you are casting robot
to FighterBot
via the "as" statement, you are storing the result in a variable of type IRobot
so Fuel
is still read only.
You need to store the result of the conversion in a variable of type FighterBot
:
var robot3 = robot as FighterBot;
Then it will work.