Duane

Duane

  • NA
  • 77
  • 0

checking equality of multi-dimensional arrays

Jul 10 2012 7:29 PM
Would the following code be the correct way to check for equality between 2 multidimensional arrays?

rivate Function AreArraysEqual(Of T)(ByVal a(,) As T, ByVal b(,) As T) As Boolean
        If a Is Nothing AndAlso b Is Nothing Then
            Return False
        End If
        If a Is Nothing Or b Is Nothing Then
            Return False
        End If
        For i As Integer = 0 To a.GetUpperBound(0)
            For j As Integer = 0 To a.GetUpperBound(1)
                If Not a(i, j).Equals(b(i, j)) Then
                    Return False
                End If
            Next
        Next
        Return True



Answers (4)