C # in comparison of two value-type one-dimensional array variables, etc.

xiaoxiao2021-03-06  14

Array == Operators and Equals methods are compared to whether the reference is equal, even if the value array is true, there is a comparison of equal value. The comparative idea is first type equal, then the length is equal, then each corresponding member value is equal.

/ ** /

///

/// Compare two value-type one-dimensional array variables are equal /// /// Vali-type one-dimensional array 1 / // Value One-dimensional array 2 /// comparison results, equal TRUE, otherwise false

public

Static

Bool

ISEquals (array array1, array array2)

{// Compare type if IF (! Object.reference (), array2.gettype ())) {Return False;} // The length is the same if (array1.getlength (0)! = Array2. GetLength (0)) {RETURN FALSE;} // The comparison member does not correspond to the equal valueType V1, V2; for (int i = 0; i

转载请注明原文地址:https://www.9cbs.com/read-48571.html

New Post(0)