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 程序运行于 Release 模式下,连续测试3次。测试结果如下: