Suppose, I have a string like "
abc, xyz, abc, efd", now I need to search "
abc" from the comma separated string, how to check if it is inside the string or not.
If possible, I would like to know the solution in Linq, thanks
using Linq you can search string as
var SearchString ="abc, xyz, abc, efd"; var ContainsStringOrNot=SearchString.Split(',').Contains("abc");
without Linq, there are several other methods like using Regex, using Array.IndexOf function
var SearchString ="abc, xyz, abc, efd"; var match=Regex.Match(SearchString , @"\abc\b"); if (match.Success) Console.WriteLine(match.Value);
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly