Best way to check for string in comma-delimited list with .NET?

Posted by Jeremy Stein on Stack Overflow See other posts from Stack Overflow or by Jeremy Stein
Published on 2010-04-06T16:44:30Z Indexed on 2010/04/06 16:53 UTC
Read the original article Hit count: 208

Filed under:
|

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.)

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET