I have this:
if (input.Text.ToUpper() == "STOP")
But there are so many possible values that I wouldn't be able to specify them all separately like this:
if (input.Text.ToUpper() == "STOP" || input.Text.ToUpper() == "END")
Is there a way that you can do something like this:
if (input.Text.ToUpper() == "STOP", "END", "NO", "YES")
So that using STOP, END, NO, or YES will do the task?
Using any contains won't work, other times accepted words will have the word STOP and END in them.
You could use a collection like array and Enumerable.Contains
:
var words = new[]{ "STOP", "END", "NO", "YES" };
if(words.Contains(input.Text.ToUpper()))
{
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With