扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
Dim Collection As String() = {"Beijing", "Shanghai", "Guangzhou", "Shenzhen", "Shijiazhuang", "Tianjin", "Taiyuan} Console.WriteLine((From City In Collection Where City(0) = "T").First) |
Sub Main() Dim Start As Integer For Count As Integer = 0 To 2 Dim Random As New Random Dim TempArray As New List(Of Integer) '生成测试数组 For I As Integer = 0 To 50000 TempArray.Add(Random.Next(10000, 99999)) Next '进行测试查询 Dim Source As Integer() = TempArray.ToArray '计算时间 '获取最后一条 Start = Timer Dim Last As Integer, First As Integer, Length As Integer For I As Integer = 0 To 500000 Last = Source.Last First = Source.First Length = Source.Count Next System.Console.WriteLine("Linq 查询数组首末与统计耗时: " & Math.Abs(Timer -Start) * 1000 & " 毫秒") '方法2: 计算时间 Start = Timer '获取最后一条 Length = Source.Length - 1 For I As Integer = 0 To 500000 Last = Source(Length - 1) First = Source(0) Length = Source.Length Next System.Console.WriteLine("传统查询数组首末与统计耗时: " & Math.Abs(Timer - Start) * 1000 & " 毫秒") Next End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者