Since this is an interface rather than a class, you will have to define your equality operator for every class that implements the interface. And those operators will need to operate consistantly. (This would be much better if it were a class rather than an interface.)
You must override the Equals(object)
and GetHashCode()
methods on each class.
Probably something like this:
public override bool Equals(object obj)
{
IFieldLookup other = obj as IFieldLookup;
if (other == null)
return false;
return other.FileName.Equals(this.FileName) && other.FieldName.Equals(this.FieldName);
}
public override int GetHashCode()
{
return FileName.GetHashCode() + FieldName.GetHashCode();
}
or this:
public override bool Equals(object obj)
{
IFieldLookup other = obj as IFieldLookup;
if (other == null)
return false;
return other.FileName.Equals(this.FileName, StringComparison.InvariantCultureIgnoreCase) && other.FieldName.Equals(this.FieldName, StringComparison.InvariantCultureIgnoreCase);
}
public override int GetHashCode()
{
return StringComparer.InvariantCulture.GetHashCode(FileName) +
StringComparer.InvariantCulture.GetHashCode(FieldName);
}
Depending on how you want it to behave.