Check if the string contains all inputs on the list

后端 未结 3 1626
囚心锁ツ
囚心锁ツ 2021-01-04 12:11

I want to be able to check if the string contains all the values held in the list; So it will only give you a \'correct answer\' if you have all the \'key words\' from the l

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-04 12:31

    Using LINQ:

    // case insensitive check to eliminate user input case differences
    var invariantText = textBox1.Text.ToUpperInvariant();
    bool matches = KeyWords.All(kw => invariantText.Contains(kw.ToUpperInvariant()));
    

提交回复
热议问题