最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
vb.net 数组元素查询方法代码
时间:2022-06-25 05:34:07 编辑:袖梨 来源:一聚教程网
vb.net 数组元素查询方法代码
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
在数组中查找一个指定元素实例
Imports System
Imports System.Collections.GenericPublic 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)
NextArray.Sort(numbers)
For Each num As String In numbers
Console.WriteLine(num)
NextDim index As Integer = Array.BinarySearch(numbers, "Four")
Console.WriteLine(index)index = Array.BinarySearch(numbers, "One")
Console.WriteLine(index)End Sub
End Class
相关文章
- 时空中的绘旅人天宇之间怎么玩 绘旅人天宇之间活动玩法介绍 12-25
- QQ2024年度报告怎么看 2024qq年度报告玩法介绍 12-25
- 归龙潮珠砂什么时候up 归龙潮红缘绮梦卡池介绍 12-25
- 王者荣耀S38赛季有什么更新 12-25
- 王者荣耀S38赛季有什么更新 王者荣耀S38赛季更新内容介绍 12-25
- 世界之外12.25有什么更新 世界之外12月25日更新内容介绍 12-25