在 C# 等面向对象的语言中,CLR 如何区分具有相同值的相同类型的对象?
例如:
class Foo
{
public string name {get; set;}
public foo(string name)
{
this.Name = name;
}
}
class Bar
{
public void Main()
{
Foo foo1 = new Foo("Jim"); //This foo is named "Jim."
Foo foo2 = new Foo("Jim"); //So is this one.
bool areEqual = (foo1 == foo2); //How is the CLR determining equivalence?
}
}