Is there a way to auto-generate GetHashCode and Equals with ReSharper?

后端 未结 4 809
独厮守ぢ
独厮守ぢ 2021-02-05 00:48

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

4条回答
  •  星月不相逢
    2021-02-05 01:28

    The Real Solution to use the Visual Studio itself. There is a built in mechanism, which can generate these functions:

    1. Place your cursor somewhere on the line of your type declaration.
    2. Click the screwdriver icon that appears in the left margin.
    3. Select Generate Equals(object) or Generate Equals and GetHashCode from the drop-down menu.

    Description with pictures: https://docs.microsoft.com/en-us/visualstudio/ide/reference/generate-equals-gethashcode-methods?view=vs-2019#how-to

提交回复
热议问题