Private Sub StartWith_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartWith.Click
Dim nickName As String = "Coperator"
Dim charLower As String = "c"
Dim charUpper As String = "C"
MsgBox("c match test")
If nickName.StartsWith(charLower) Then
MsgBox("Coperator mach c success")
Else
MsgBox("Coperator mach c fail")
End If
MsgBox("C match test")
If nickName.StartsWith(charUpper) Then
MsgBox("Coperator mach C success")
Else
MsgBox("Coperator mach C fail")
End If
End Sub
Dim nickName As String = "Coperator"
Dim charLower As String = "c"
Dim charUpper As String = "C"
MsgBox("c match test")
If nickName.StartsWith(charLower) Then
MsgBox("Coperator mach c success")
Else
MsgBox("Coperator mach c fail")
End If
MsgBox("C match test")
If nickName.StartsWith(charUpper) Then
MsgBox("Coperator mach C success")
Else
MsgBox("Coperator mach C fail")
End If
End Sub

本文通过一个简单的示例演示了如何使用 StartsWith 方法来判断字符串是否以特定字符开始。示例中定义了一个名为 Coperator 的昵称,并分别用大写 'C' 和小写 'c' 进行匹配测试。
1171

被折叠的 条评论
为什么被折叠?



