IList Reference Equal - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IList

Description

IList Reference Equal

Demo Code


using System.Linq;
using System.Collections.Generic;
using System;//w w w .  j  av a2  s.  com

public class Main{
        public static bool ArraysReferenceEqual<T>(IList<T> a1, IList<T> a2) where T : class
        {
            if (ReferenceEquals(a1, a2))
                return true;

            if (a1 == null || a2 == null)
                return false;

            if (a1.Count != a2.Count)
                return false;

            for (int i = 0; i < a1.Count; i++)
            {
                if (a1[i] != a2[i])
                    return false;
            }

            return true;
        }
}

Related Tutorials