Skip to content

Latest commit

 

History

History
46 lines (29 loc) · 1.57 KB

generate-equals-structs.md

File metadata and controls

46 lines (29 loc) · 1.57 KB
title description ms.date ms.topic author ms.author manager ms.subservice
Generate IEquatable operators for structs
Learn how to use the Quick Actions and Refactorings menu to generate Equals and IEquatable operators for structs.
05/12/2020
reference
mikadumont
midumont
mijacobs
general-ide

Generate IEquatable operators when generating Equals for structs

This code generation applies to:

  • C#

What: Lets you generate Equals and IEquatable operators for structs.

When: You have a struct we will automatically add the IEquatable as well as the equals and not equals operators for you.

Why:

  • If you are implementing a value type, you should consider overriding the Equals method to gain increased performance over the default implementation of the Equals method on ValueType.

  • Implement IEquatable interface implements a type-specific Equals() method.

How-to

  1. Place your cursor somewhere on the line of your struct declaration.

  2. Next, do one of the following:

    • Press Ctrl+. to trigger the Quick Actions and Refactorings menu.

    • Right-click and select the Quick Actions and Refactorings menu.

    • Click the screwdriver icon that appears in the left margin.

    Generate IEquatable and Equals for structs

  3. Select Generate Equals(object) from the drop-down menu.

See also