我已经覆盖GetHashCode
,Equals
并且两种方法都为不同的对象提供了相同的结果,但为什么仍然得到 false ?
class Program
{
static void Main(string[] args)
{
Console.WriteLine(new Person("james") == new Person("james"));
Console.ReadKey();
}
}
class Person
{
private string Name;
public Person(string name)
{
Name = name;
}
public override int GetHashCode()
{
return 1;
}
public override bool Equals(object obj)
{
return true;
}
}