Пример #1
0
        /// <summary>Compares this instance to a specified instance and returns an indication of their relative values.</summary>
        /// <param name="other">An instance to compare.</param>
        /// <returns>
        /// A signed number indicating the relative values of this instance and <paramref name="other"/>.
        /// Returns less than zero if this instance is less than <paramref name="other"/>, zero if this
        /// instance is equal to <paramref name="other"/>, and greater than zero if this instance is greater
        /// than <paramref name="other"/>.
        /// </returns>
        public int CompareTo(ValueTupleCached <T1, T2, T3, T4> other)
        {
            int c = Comparer <T1> .Default.Compare(Item1, other.Item1);

            if (c != 0)
            {
                return(c);
            }

            c = Comparer <T2> .Default.Compare(Item2, other.Item2);

            if (c != 0)
            {
                return(c);
            }

            c = Comparer <T3> .Default.Compare(Item3, other.Item3);

            if (c != 0)
            {
                return(c);
            }

            return(Comparer <T4> .Default.Compare(Item4, other.Item4));
        }
Пример #2
0
 /// <summary>
 /// Returns a value that indicates whether the current <see cref="ValueTupleCached{T1, T2, T3, T4}"/>
 /// instance is equal to a specified <see cref="ValueTupleCached{T1, T2, T3, T4}"/>.
 /// </summary>
 /// <param name="other">The tuple to compare with this instance.</param>
 /// <returns><see langword="true"/> if the current instance is equal to the specified tuple; otherwise, <see langword="false"/>.</returns>
 /// <remarks>
 /// The <paramref name="other"/> parameter is considered to be equal to the current instance if each of its fields
 /// are equal to that of the current instance, using the default comparer for that field's type.
 /// </remarks>
 public bool Equals(ValueTupleCached <T1, T2, T3, T4> other)
 {
     return(T1Comparer.Equals(Item1, other.Item1) &&
            T2Comparer.Equals(Item2, other.Item2) &&
            T3Comparer.Equals(Item3, other.Item3) &&
            T4Comparer.Equals(Item4, other.Item4));
 }