A Method to Perform Array Value Equality Comparisons

Recall our earlier discussion about reference and value equality. Equipped with an understanding for how array object references are passed as arguments to a method, we can now design a method that determines whether two arrays are value equal to each other. The ValueEquals method (lines 21–41) of Listing 10.9 contains this functionality. The Main() method demonstrates how ValueEquals is used. It declares two array variables each referencing different objects, but with identical sets of array elements (lines 7 and 8). The following sample output verifies the difference between value equality as performed by the ValueEquals method, and reference equality performed by the equals comparison operator ...

Get C# Primer Plus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.