As the title says my list \"Cvqt\" contains different strings for example \"1 maxHearts Player\" and I\'m trying to check if it contains \" maxHearths \" + na
When you do Contains on a List it only checks if the list contains a string that is a exact match to what you are passing in, it will not do a partial match.
If you want partial matches you need to do something more complicated like
if (Cvqt.Any(x=>x.Contains(" maxClubs " + name)))
{
Cvqt.Remove(maxClubs.ToString() + " maxClub " + name);
}
or
var item = Cvqt.FirstOrDefault(x => x.Contains(" maxClubs " + name));
if (item != null)
{
Cvqt.Remove(item);
}
if you want to remove the found item instead of the specific string using maxClubs.
What those two methods do is call String.Contains on each item instead of ListList is the same as doing a Object.Equals(T t1, T listItem) on each item in the list.