I'm coding with a state pattern for an embedded device. I have a base/abstract class called State and then each discrete(concrete) state class implements the abstract State Class.
In the State Class I have several Abstract Methods. If I don't implement the abstract methods in the discrete(concrete) class, Visual Studio will give an error something like this:
...Error 1 'myConcreteState' does not implement inherited abstract member 'myAbstractState'
Now: I'm trying to create a String property for each State called StateName. Whenever I create a new concrete class, I need to define StateName. I want VS to throw an error if I don't use it. Is there a simple way to do this?
I've tried this in the abstract/base class:
public abstract string StateName { get; set; }
But I don't need to implement the Get and Set methods in each State.
Revised Question: In an ideal situation, each State Class would be required to have StateName defines and be inherited from the abstract base class.
StateName = "MyState1"; //or whatever the state's name is
If that statement is missing then Visual Studio will generate an error as described above. Is this possible and if so, how?