更新时间:2023-11-25 21:47:46
<System.Runtime.CompilerServices.Extension()> _
Function AreItemsEqual(Of T)(col1 As IEnumerable(Of T), col2 As IEnumerable(Of T)) As Boolean
' performance checks
If col1 Is col2 Then Return True
If col1 Is Nothing OrElse col2 Is Nothing Then Return False
If col1.Count <> col2.Count Then Return False
' compare their elements
Dim o1 As IEnumerable(Of T) = col1.OrderBy(Function(i) i)
Dim o2 As IEnumerable(Of T) = col2.OrderBy(Function(i) i)
Return o1.SequenceEqual(o2)
End Function
b $ b
用法:
Usage:
If list1.AreItemsEqual(list2) Then
...