Check if a string contains an element from a list (of strings)

后端 未结 11 2058
盖世英雄少女心
盖世英雄少女心 2020-11-27 11:09

For the following block of code:

For I = 0 To listOfStrings.Count - 1
    If myString.Contains(lstOfStrings.Item(I)) Then
        Return True
    End If
Next         


        
11条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 11:32

    Old question. But since VB.NET was the original requirement. Using the same values of the accepted answer:

    listOfStrings.Any(Function(s) myString.Contains(s))
    

提交回复
热议问题