Example #1
0
 /// <summary>
 /// 指示当前对象是否等于同一类型的另一个对象。
 /// </summary>
 /// <param name="other">与此对象进行比较的对象。</param>
 /// <returns>如果当前对象等于 <paramref name="other"/> 参数,
 /// 则为 <c>true</c>;否则为 <c>false</c>。</returns>
 /// <overloads>
 /// <summary>
 /// 指示当前对象是否等于另一个对象。
 /// </summary>
 /// </overloads>
 public bool Equals(TextValuePair <TValue> other)
 {
     if (ReferenceEquals(other, this))
     {
         return(true);
     }
     if (ReferenceEquals(other, null))
     {
         return(false);
     }
     if (!string.Equals(text, other.text, StringComparison.CurrentCulture))
     {
         return(false);
     }
     return(EqualityComparer <TValue> .Default.Equals(pairValue, other.pairValue));
 }
Example #2
0
        /// <summary>
        /// 确定指定的 <see cref="Object"/> 是否等于当前的 <see cref="TextValuePair{TValue}"/>。
        /// </summary>
        /// <param name="obj">与当前的 <see cref="TextValuePair{TValue}"/>
        /// 进行比较的 <see cref="Object"/>。</param>
        /// <returns>如果指定的 <see cref="Object"/> 等于当前的 <see cref="TextValuePair{TValue}"/>,
        /// 则为 <c>true</c>;否则为 <c>false</c>。</returns>
        public override bool Equals(object obj)
        {
            TextValuePair <TValue> thisObj = obj as TextValuePair <TValue>;

            return(!ReferenceEquals(thisObj, null) && this.Equals(thisObj));
        }