How can I restrict string values being passed into my method to ˇ°Openˇ±, ˇ°Closeˇ±, ˇ°Highˇ± and ˇ°Lowˇ±
Thanks
Visual C# General
How can I restrict string values being passed into my method to ˇ°Openˇ±, ˇ°Closeˇ±, ˇ°Highˇ± and ˇ°Lowˇ±
Thanks
The easiest way is probably to define an enum type with those values, and validate in the method that one of the defined enum values was passed in.
enum Values
{
}
void MyFunction(Values value)
{
}
Yep Enum.
You stated your options for teh string and there is no spaces .
However if there is I guess for simplicity you could create a string array or list containing your values and use the Contains method no the list to check the entry is allowed.
Otherwise use an Enum