In eclipse, when I code in Java, there is a feature to auto-generate a basic, efficient, and bug free implementation of hashCode() and equals() without consuming brain power.
Is there a similar feature either built-in in Visual Studio or in ReSharper ?
Yes, Resharper can do that. With cursor inside your type, open the “Generate code” menu (Alt+Ins depending on settings or Resharper -> Edit -> Generate Code), and select “Equality members”:
This opens a window where you can select which members are used for equality, along with some options about the generated code (e.g. should your type implement
IEquatable<T>):If you start with a simple type with two properties:
Then the generated code may look something like: