Skip to content

Latest commit

 

History

History
42 lines (27 loc) · 1.41 KB

generate-comparison-operators.md

File metadata and controls

42 lines (27 loc) · 1.41 KB
title description ms.date ms.topic author ms.author manager ms.subservice
Generate Comparison Operators for IComparable
For increased performance, generate Comparison Operators for types that implement IComparable.
05/12/2020
reference
mikadumont
midumont
mijacobs
general-ide

Generate Comparison Operators for types that implement IComparable

This code generation applies to:

  • C#

What: Lets you generate Comparison operators for types that implement IComparable.

When: You have a type that implements IComparable we will automatically add the comparison operators.

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.

How-to

  1. Place your cursor either inside the class or on the IComparable keyword.

  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 Comparison Operators

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

See also