ReSharper
 
Get ReSharper
You are viewing the documentation for an earlier version of ReSharper.

Generate Relational Members

Last modified: 21 July 2022

ReSharper | Edit | Generate Code | Relational Members

Alt+Insert | Relational Members (ReSharper_GenerateRelationalMembers)

ReSharper helps you automatically overload relational operators and implementations of related interfaces using selected fields and properties. By default, ReSharper will create an implementation of IComparable<T>, and optionally, operators >, <, and as well as an implementation of IComparable are generated too.

In the example below, this command is used to generate relational members that takes into account int _birthYear and string _name fields when to compare objects of the Person class.

This feature is supported in the following languages and technologies:

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see corresponding topics in the ReSharper by language section.