JetBrains Rider
 
Get JetBrains Rider
Get your hands on the new features ahead of the release by joining the Early Access Program for Rider 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.

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

Depending on the target C# version, JetBrains Rider 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().