G
Guinness Mann
resource.cs(8,15): warning CS0659: 'UA.LMS.Resource.Resource' overrides
Object.Equals(object o) but does not override Object.GetHashCode()
What does this mean? I mean I know what it says, but do I need to do
anything? If I specify exactly how to do the comparison why would I
need to provide a hashcode override?
Here are the interesting pieces of my class:
public class Resource
{
public int rId;
public string language;
public string caption;
(Various constructors elided)
public static bool operator==(Resource lhs, Resource rhs)
{
if
( (lhs.rId == rhs.rId)
&& (lhs.language == rhs.language)
&& (lhs.caption == rhs.caption)
)
{
return true;
}
return false;
}
public static bool operator !=(Resource lhs, Resource rhs)
{
return !(lhs == rhs);
}
public override bool Equals(object obj)
{
if (! (obj is Resource))
return false;
return this == (Resource)obj;
}
}
Object.Equals(object o) but does not override Object.GetHashCode()
What does this mean? I mean I know what it says, but do I need to do
anything? If I specify exactly how to do the comparison why would I
need to provide a hashcode override?
Here are the interesting pieces of my class:
public class Resource
{
public int rId;
public string language;
public string caption;
(Various constructors elided)
public static bool operator==(Resource lhs, Resource rhs)
{
if
( (lhs.rId == rhs.rId)
&& (lhs.language == rhs.language)
&& (lhs.caption == rhs.caption)
)
{
return true;
}
return false;
}
public static bool operator !=(Resource lhs, Resource rhs)
{
return !(lhs == rhs);
}
public override bool Equals(object obj)
{
if (! (obj is Resource))
return false;
return this == (Resource)obj;
}
}