Mega Code Archive

 
Categories / VB.Net Tutorial / Data Type
 

Use IndexOfAny to find first occurrence of character in array

Module Tester    Sub Main()       Dim letters As String = "abcdefghijklmabcdefghijklm"       Dim searchLetters As Char() = New Char() {"c"c, "a"c, "$"c}       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  End Module First occurrence of "c", "a" or "$" is located at 0 First occurrence of "c", "a" or "$" is located at 13 First occurrence of "c", "a" or "$" is located at -1