System.Attribute.Equals C# (CSharp) Method

Equals() public method

public Equals ( Object obj ) : bool
obj Object
return bool
        public override bool Equals(Object obj)
        {
             if (obj == null) 
                return false;
             
             RuntimeType thisType = (RuntimeType)this.GetType();
             RuntimeType thatType = (RuntimeType)obj.GetType();
 
             if (thatType != thisType) 
                return false;
 
             Object thisObj = this;
             Object thisResult, thatResult;
 
             FieldInfo[] thisFields = thisType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            
             for (int i=0; i<thisFields.Length; i++) 
             {
                thisResult = ((RuntimeFieldInfo)thisFields[i]).GetValue(thisObj);
                thatResult = ((RuntimeFieldInfo)thisFields[i]).GetValue(obj);
    
                if (thisResult == null) 
                {
                     if (thatResult != null)
                      return false;
                }
                else if (!thisResult.Equals(thatResult)) 
                {
                    return false;
                }
            }
 
            return true;
        }

Usage Example

		public bool Contains (Attribute attr)
		{
			Attribute at = this [attr.GetType ()];
			if (at != null)
				return attr.Equals (at);
			else
				return false;
		}
All Usage Examples Of System.Attribute::Equals