ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Generate Formatting Members

Last modified: 26 May 2024

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 more information about other languages, refer to corresponding topics in the Languages and frameworks section.