Generating Formatting Members
Any type in .NET implements the
method, which returns a string representation of the object of that type.
To return a meaningful string for our types, we often need to override the
In the example below, this command is used to generate the
method based on
|Before generation||After generation|
To generate overrides for formatting members
- In the editor, set the caret on the type name or within a type at the line where you want to insert overrides for formatting members. If the caret is on the type name, generated code will be added in the beginning of the type declaration.
dialog that appears, select fields and/or auto-properties to be used in the
If there are no fields/properties in your type or you do not select any of them, ReSharper, depending on your settings, throws new
NotImplementedException(), returns default value, or puts code that will not compile in the body of the generated methods. You can configure the settings on the page of ReSharper options.
Optionally, use the following controls in the dialog:
to complete the wizard.
You can also click Options to review or modify common code generation preferences on the page of ReSharper options.
You can also generate the override by choosing
menu, but in this case the override will return
This feature is supported in the following languages/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.