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

Generate Formatting Members

Last modified: 30 September 2021

Code | Generate | Formatting Members

Alt+Insert | Formatting Members

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().