I was given a new project at work, and I am very new to c#.
I have a base class that will be derived many times, and so I am trying to come up with a way to check if a derived class contains a const string
value from a .contains()
method implemented in the base class. I cannot use a string array because I have to reference the string values by variable name when I am making calls to other methods in the derived class. The reason I want the base class to implement it is this project will be used for many years at my company, and once I pass it off, new hires will be the ones implementing the base class.
I don't want to implement multiple data structures to achieve this, i.e. a string array and an enum, for simplicity sakes.
What I want is something like this:
public abstract class Base
{
public bool contains(string s)
{
// some implementation here
// this would return true if SomeDataStructure
// contains a const string == s
}
}
public Derived : Base
{
SomeDataStructure {
const string = "string 1";
const string = "string 2";
const string = "string 3";
}
}
Is this possible, and if so, what data structure and implementation would I use?
Thanks!