List.Contains() doesn't detects a string

前端 未结 3 672
眼角桃花
眼角桃花 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:11

    Contains as it pertains to a List object looks for the entire string in a list of strings.

    You are looking for "max clubs" as a substring. That is the "Contains" off the string object

    Example:

    List x = new List(){"Hello", "goodbye"};
    bool y = x.Contains("good"); // will be false
    y = x.Contains("goodbye"); // will be true
    
    y = x[0].Contains("Hell"); // will be true
    

    You're probably looking for something like this:

    List stringsWithMaxClubs = Cvqt.Where(argString => argString.Contains(" maxClubs " + name)).ToList();
    

提交回复
热议问题