Best way to check for string in comma-delimited list with .NET?
- by Jeremy Stein
I'm reading a comma-delimited list of strings from a config file. I need to check whether another string is in that list. For example:
"apple,banana,cheese"
If I check for "apple" I should find it, but if I check for "app" I should not.
What's the most straight-forward and concise way to do this? It doesn't have to be fast.
(I'll add my solution as an answer, but I'm hoping someone has something better.)