Vb.net array element query method code
Imports System
Public Class Example
Public Shared Sub Main ()
Dim letters () As String = {"E", "B", "A", "Z", "D", "X", "Y", "Q "}
Console. WriteLine (Array. Find (letters, AddressOf EndsWithS ))
Dim subArray () As String = Array. FindAll (letters, AddressOf EndsWithS)
For Each letter As String In subArray
Console. WriteLine (letter)
Next
End Sub
Private Shared Function EndsWithS (ByVal s As String) As Boolean
If (s. Length> 5) AndAlso (s. Substring (s. Length-6). ToLower () = "S") Then
Return True
Else
Return False
End If
End Function
End Class
Searches for an instance of a specified Element in the array.
Imports System
Imports System. Collections. Generic
Public Class Example
Public Shared Sub Main ()
Dim numbers () As String = {"Ten", "Two", "One", "Three", "Four", "Nine "}
For Each num As String In numbers
Console. WriteLine (num)
Next
Array. Sort (numbers)
For Each num As String In numbers
Console. WriteLine (num)
Next
Dim index As Integer = Array. BinarySearch (numbers, "Four ")
Console. WriteLine (index)
Index = Array. BinarySearch (numbers, "One ")
Console. WriteLine (index)
End Sub
End Class