Should I forward the a call to .Equals onto .Equals<T>?
- by Jaimal Chohan
So, I've got you bog standard c# object, overriding Equalsand implementing IEquatable
public override int GetHashCode()
{
return _name.GetHashCode();
}
public override bool Equals(object obj)
{
return Equals(obj as Tag)
}
#region IEquatable<Tag> Members
public bool Equals(Tag other)
{
if (other == null)
return false;
else
return _name == other._name;
}
#endregion
Now, for some reason, I used to think that forwarding the calls from Equals into Equals was bad, no idea why, perhaps I read it a long time ago, anyway I'd write separate (but logically same) code for each method.
Now I think forwarding Equals to Equals is okay, for obvious reasons, but for the life me I can't remember why I thought it wasn't before.
Any thoughts?