I have a List of strings as follows,
List<string> str = new List<string>() { "7, 31", "2, 4", "5, 6" };
My input will be something like "1, 2" or "1"
Is there a way to compare if any item in the list of strings exactly matches with the input. In the above case it should return a false. But if my input was "31" it should give me a true or if my input was "7, 31", also it should give true.
I try this code but it always returns true.
bool res = false;
List<string> substrings = new List<string>() { "7, 31", "2, 4", "5, 6" };
string input = "1"; //Because my input can be "1" or "1, 31" etc spltting it.
var inputSplitted = input.Split(',');
var plates = substrings.Select(x => x.Split(','));
foreach (var item in plates)
{
if (item.Any() == inputSplitted.Any())
{
res = true;
}
}
Console.WriteLine(res);