I am trying to figure out how to determine if a string / does not contain a list value, but also contains, but with a different value.
If I have an input line:
string inputString = "it was one";
and I want to find a specific value for the condition:
var numbList = new List<string> {"zero", "one", "two"}; if (!numbList.Any(inputString.Contains)) { Console.WriteLine("string does not contains list value"); } else { Console.WriteLine("string contains list value"); }
But I'm not sure what is right if I want to know also about the third condition, if the string contains a value, but also contains other words.
For string: inputString = "it was one"; The desired result should be:
Console.WriteLine("string contains list value and other words");
for string: inputString = "one";
Console.WriteLine("string contains list value");
and for: inputString = "it was";
Console.WriteLine( "string does not contains list value");
source share