Generate Formatting Members

Last modified: 07 April 2022

ReSharper | Edit | Generate Code | Formatting Members

Alt+Insert | Formatting Members (ReSharper_GenerateFormattingMembers)

Any type in .NET implements the ToString() method, which returns a string representation of an object of the type. To return a meaningful string for our types, we often need to override the ToString() method.

ReSharper allows you to automate this routine with the Generate formatting members command.

Depending on the target C# version, ReSharper either uses interpolated string or String.Format(). Note that you can always convert between those with context actions Alt+Enter.

In the example below, this command is used to generate the ToString() method based on _radius and _center fields.

You can also generate the override by choosing Overriding Members in the Generate menu, but in this case the override will return base.ToString().

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.