[VB.Net] 使用Distinct

VB.Net使用Distinct 

Imports System.Linq

Dim values As New List(Of Integer)
Dim val1 As Integer = 0
Dim val2 As Integer = 1
Dim val3 As Integer = 1

values.Add(val1)
values.Add(val2)
values.Add(val3)

' 判斷 List 是否有重複數字'
If values.Count <> values.Distinct().Count() Then
    Console.WriteLine("發現重複數值")
Else
    Console.WriteLine("順序未重複")
End If
參考網址: 
By Hao★

留言

熱門文章

[VB.Net] 連接資料庫並將資料顯示在DataGride中

[VB.Net] 使用 ClosedXML將DataGridView 匯出至 Excel

[Java] equals()、equalsIgnoreCase()