[Mono-list] Enum.Equals() confusion

Nick Drochak ndrochak@gol.com
Mon, 18 Mar 2002 07:34:47 +0900


| > enum TestingEnum {This, Is, A, Test};
| > enum TestingEnum2 {This, Is, A, Test};
| > ...
| > Enum e1 = new TestingEnum();
| > Enum e2 = new TestingEnum();
| > Enum e3 = new TestingEnum2();
| > 
| > bool b1 = e1.Equals(e2);
| > bool b2 = e1.Equals(e3);
| > bool b3 = TestingEnum.Test.Equals(TestingEnum2.Test);

| The correct answer is:
| b1 = True
| b2 = False
| b3 = False
| 
| The Equals() method determines whether the objects are 
| equivalent not whether they are the same object.  Thus B1 is 
| true.  B2 is false because they operands are obviously not 
| even of the same type.  And B3 is false because the operands 
| are again not the same.

Thank you.  That answers part of it.

But, I'm still a little confused about how to implement Enum.Equals().
Is the same Equals method called in the case of b1 and b3? If so, how
does it know?

Thanks,
Nick