Are Arrays Equal - CSharp System

CSharp examples for System:Array Equal

Description

Are Arrays Equal

Demo Code


using System.Collections.Generic;
using System;/*  w  ww .  j  ava 2s.co  m*/

public class Main{
        public static bool AreArraysEqual(Array a1, Array a2)
    {
      if (a1 == null && a2 == null) return true;
      if (a1 == null || a2 == null) return false;
      if (a1.Length != a2.Length) return false;
      for (var i = 0; i < a1.Length; ++i)
      {
        if (!Equals(a1.GetValue(i), a2.GetValue(i)))
          return false;
      }
      return true;
    }
}

Related Tutorials