Mega Code Archive

 
Categories / VB.Net Tutorial / Data Type
 

Use LastIndexOfAny 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("Last occurrence of ""c""," & _          " ""a"" or ""$"" is located at " & _          letters.LastIndexOfAny(searchLetters))       Console.WriteLine("Last occurrence of ""c"", ""a"" or " & _          """$"" is located at " & _          letters.LastIndexOfAny(searchLetters, 1))       Console.WriteLine("Last occurrence of ""c"", ""a"" or " & _          """$"" is located at " & _          letters.LastIndexOfAny(searchLetters, 25, 5))              End Sub  End Module Last occurrence of "c", "a" or "$" is located at 15 Last occurrence of "c", "a" or "$" is located at 0 Last occurrence of "c", "a" or "$" is located at -1