Module Module1
Sub Main()
Dim s() As String = {"PHP", "C", "C++", "C#", "Java", "JavaScript",
"VB.NET", "VB6", "Pascal", "Python"}
Dim characters() As Char = {"C"c, "J"c, "V"c, "P"c, "D"c}
For Each ch In characters
Console.WriteLine("One or more strings begin with '{0}': {1}",
ch,
Array.Exists(s, AddressOf (New SearchString(ch)).StartsWith))
Next
End Sub
Public Class SearchString
Dim firstChar As Char
Public Sub New(firstChar As Char)
Me.firstChar = Char.ToUpper(firstChar)
End Sub
Public Function StartsWith(s As String) As Boolean
If String.IsNullOrEmpty(s) Then Return False
If s.Substring(0, 1).ToUpper = firstChar Then
Return True
Else
Return False
End If
End Function
End Class
End Module
' run:
'
' One or more strings begin with 'C': True
' One Or more strings begin with 'J': True
' One Or more strings begin with 'V': True
' One Or more strings begin with 'P': True
' One Or more strings begin with 'D': False