System.Collections.Specialized.CompatibleComparer.Equals C# (CSharp) Method

Equals() public method

public Equals ( Object a, Object b ) : bool
a Object
b Object
return bool
        public new bool Equals(Object a, Object b) {
            if (a == b) return true;
            if (a == null || b == null) return false;
            
            // We must call Compare or CompareTo method
            // to make sure everything is fine, but the 
            // guideline is that Equals should never throw.
            // So we need to swallow ArgumentException (note this
            // is the exception we should get if two objects are not
            // comparable.)

            try {
                if (_comparer != null)
                    return (_comparer.Compare(a,b) == 0);

                IComparable ia = a as IComparable;
                if (ia != null)
                    return (ia.CompareTo(b) ==0);
            }
            catch(ArgumentException) {
                return false;
            }

            return a.Equals(b);
        }