Better way to check a list of characters?
There has to be a better way than doing this
I also don't really want to make a array and have to loop through them all because that seems like code would pile up quickly. I'm hoping for a function that does what I'm looking for?
6 Replies
Or you could make an extension method or something, say
used with
myWord is "-" or "~" or ...
Duh, of course, how could I forget about pattern matching...
If all single letter,
"-~—…”.Contains(letter)
If you are trying see if a string contains any of the characters you specify then:
Note this only works with constants, unfortunately.