Skip to content

Instantly share code, notes, and snippets.

@kjnilsson
Created January 29, 2015 12:34
Show Gist options
  • Save kjnilsson/be28e7d43e9b963c4455 to your computer and use it in GitHub Desktop.
Save kjnilsson/be28e7d43e9b963c4455 to your computer and use it in GitHub Desktop.
sharp and equality
public class CodeListElement
{
private readonly int codeContext;
private readonly string value;
public CodeListElement(int codeContext, string value)
{
this.codeContext = codeContext;
this.value = value;
}
public string Value
{
get { return this.value; }
}
public int CodeContext
{
get { return this.codeContext; }
}
protected bool Equals(PadisCodeListElement other)
{
return codeContext == other.codeContext && string.Equals(value, other.value);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((PadisCodeListElement) obj);
}
public override int GetHashCode()
{
unchecked
{
return (codeContext*397) ^ (value != null ? value.GetHashCode() : 0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment