Check if two array are equal - CSharp System

CSharp examples for System:Array Equal

Description

Check if two array are equal

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from   w  w w  .j av a  2s .  c  om

public class Main{
        /// <summary>
      /// Believe it or not, .NET has no such method by default.
      /// Array.Equals is not overridden properly.
      /// </summary>
      public static bool EqualValues<T>(this T[] arr, T[] arr2)
         where T : struct
      {
         for (var i = 0; i < arr.Length; i++)
         {
            if (!arr[i].Equals(arr2[i]))
            {
               return false;
            }
         }
         return true;
      }
}

Related Tutorials