I summarized my question in the following code snippet
struct Point
{
public int X;
public int Y;
public Point(int x, int y)
{
this.X = x;
this.Y = y;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public void PrintValue()
{
Console.WriteLine(
"{0},{1}",
this.X, this.Y);
}
}
the above struct is derived from ValueType, which contains the GetHashCode method. Below is the version of the class that is inferred from the object and contains a method GetHashCode.
class Point
{
public int X;
public int Y;
public Point(int x, int y)
{
this.X = x;
this.Y = y;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public void PrintValue()
{
Console.WriteLine(
"{0},{1}",
this.X, this.Y);
}
}
I just wanted to know. Is there any difference between these implementations?
source
share