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\"
This is solution for ignoring case and culture(or select one of the property of StringComparer
)
var commaDelimitedString = "string1,string2,string3,string4";
var testString = string2.trim; // trim to remove the spaces coz you may be getting it from UI
if(commaDelimitedString.split(',').contains(testString,StringComparer.InvariantCultureIgnoreCase))
{
//TODO: What to do when condition is true
}
else
{
//TODO: What to do when condition is false
}