Having programmed in Java and C#, I have said that C# is marginally a better
language than Java. Well, now I can claim that, at least for one reason.
I tried the following code in Java (Java 5):
public class MyClass
{
public boolean
equals(Object obj)
{
return super.equals(obj);
}
}
It compiled with no error or warning.
I tried similar code in C#.
public class MyClass
{
public override bool Equals(object obj)
{
return base.Equals
(obj);
}
}
You will get a warning (actually I got an error since I Treat Warnings as Error ? see Gotcha #12).
warning CS0659: 'TestApp.MyClass' overrides Object.Equals(object o) but does not override Object.GetHashCode()
>
I am glad to see that the C# compiler creators have followed Joshua Bloch?s recommendation
(Item #8) in
Effective Java Programming
Langauge Guide.