Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
3,157 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have the code below, do I have to use the loop? Is there a better way? thank you.
Dim result As Boolean
Dim a As New List(Of String)
a.Add("abcd")
a.Add("qwer")
Dim x As String = "abcdef"
For Each s As String In a
If x.Contains(s) = True Then
result = True
End If
Next
Try this alternative:
Dim a As New List(Of String) From {"abcd", "qwer"}
Dim x As String = "abcdef"
Dim result As Boolean = a.Any(AddressOf x.Contains)