There’s a few things I’d reconsider in this code Scalpel.
First there’s nothing to be gained by representing different states with different classes, you can but it adds nothing helpful.
It may be better to define an enum - and list each of the states you want to represent as distinct enum members.
Then wherever you want to store a state value, just declare and use and instance of the enum.
For example we might have:
public enum State
Dormant, // i.e. parked, no key in ignition
and so on…
You can then have a member (field) in your ‘Car’ object of type ‘State’ - that field is then the state of the car.
It’s easy to compare enum and write code like this:
if (_currentState == State.Driving && desiredAction == Action.Start)
/// perhaps report an error…
You probably get the idea, basically your over-designing the way you represent state - unless there’s more to your work than I can see currently.
If you really must compare as you are, then because each state is a different class you can just compare their types:
if (state_a.GetType() == state_b.GetType()) // same…
if (state_a is StateWaiting) // etc etc…