IndexOfAny to find first occurrence of character in array
Imports System
Public Class MainClass
Shared Sub Main()
Dim letters As String = "abcdefghijklmabcdefghijklm"
Dim searchLetters As Char() = New Char() {"c"c, "a"c, "$"c}
Console.WriteLine("IndexOfAny to find first occurrence of character in array")
Console.WriteLine("First occurrence of ""c""," & _
" ""a"" or ""$"" is located at " & _
letters.IndexOfAny(searchLetters))
Console.WriteLine("First occurrence of ""c"", ""a"" or " & _
"""$"" is located at " & _
letters.IndexOfAny(searchLetters, 7))
Console.WriteLine("First occurrence of ""c"", ""a"" or " & _
"""$"" is located at " & _
letters.IndexOfAny(searchLetters, 20, 5))
End Sub ' Main
End Class
Related examples in the same category