test if two arrays are equal in contents; arrays should have same type - CSharp System

CSharp examples for System:Type

Description

test if two arrays are equal in contents; arrays should have same type

Demo Code


using System.Reflection;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from   www . ja  va 2s . co  m*/

public class Main{
        /// <summary>
      /// test if two arrays are equal in contents; arrays should have same type
      /// </summary>
      /// <typeparam name="T"></typeparam>
      /// <param name="o1"></param>
      /// <param name="o2"></param>
      /// <returns></returns>
      private static bool ArrayEquals<T>(T[] o1, T[] o2)
      {
         if (o1.Length != o2.Length)
         {
            return false;
         }
         for (int i = 0; i < o1.Length; i++)
         {
            if (!DeepEquals(o1[i], o2[i]))
               return false;
         }
         return true;
      }
}

Related Tutorials