Employee emp1 = new Employee {Name = "Swapnil",Age = 27 };
Employee emp2 = new Employee { Name = "Swapnil", Age = 27 };
if (object.Equals(emp1, emp2))
{
}
else
{
}
这段代码无法进行比较。 在C#中如何比较两个对象?
Equals
和GetHashCode
吗? - Jon Skeet