List.Contains() doesn't detects a string

前端 未结 3 670
眼角桃花
眼角桃花 2021-01-25 09:44

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

3条回答
  •  迷失自我
    2021-01-25 10:12

    Your list contains strings in the form of maxClubs + " maxClubs " + name while you're searching for " maxClubs " + name. There will be no element in your list that exactly matches this (unless maxClubs is an empty string).

    You can use Linq Any for what you want:

    if (Cvqt.Any(x => x.Contains(" maxClubs " + name)))
    {
    }
    

提交回复
热议问题