Object.ToString Method (System) (original) (raw)

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Returns a string that represents the current object.

public:
 virtual System::String ^ ToString();
public virtual string ToString();
public virtual string? ToString();
abstract member ToString : unit -> string
override this.ToString : unit -> string
Public Overridable Function ToString () As String

Returns

A string that represents the current object.

Remarks

For more information about this API, see Supplemental API remarks for Object.ToString.

Notes to Inheritors

When you implement your own types, you should override the ToString() method to return values that are meaningful for those types. Derived classes that require more control over formatting than ToString() provides can implement the IFormattable interface. Its ToString(String, IFormatProvider) method enables you to define format strings that control formatting and to use an IFormatProvider object that can provide for culture-specific formatting.

Overrides of the ToString() method should follow these guidelines:

Applies to

See also