Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Object.ToString Method

Returns a String that represents the current Object.

[Visual Basic]
Public Overridable Function ToString() As String
public virtual string ToString();
public: virtual String* ToString();
public function ToString() : String;

Return Value

A String that represents the current Object.


This method returns a human-readable string that is culture-sensitive. For example, for an instance of the Double class whose value is zero, the implementation of Double.ToString might return "0.00" or "0,00" depending on the current UI culture.

The default implementation returns the fully qualified name of the type of the Object.

Notes to Implementers:  This method can be overridden in a derived class to return values that are meaningful for that type. For example, the base data types, such as Int32, implement ToString so that it returns the string form of the value that the object represents. Derived classes that require more control over the formatting of strings than ToString provides must implement IFormattable, whose ToString method uses the current thread's CurrentCulture property.


[Visual Basic, C#, C++] The following code example demonstrates what ToString returns.

[Visual Basic] 
Imports System

Public Class Sample
    Sub Method()

        ' Prints out: "System.Object"
        Dim o As New Object()

    End Sub 'Method
End Class 'Sample

using System;

public class Sample
    void Method() {

        // Prints out: "System.Object"
        Object o = new Object();
        Console.WriteLine (o.ToString());


#using <mscorlib.dll>
#using <System.DLL>

using namespace System;

__gc class Sample
   void Method()

      // Prints out: "System.Object"
      Object *o = new Object();
      Console::WriteLine (o->ToString());


[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Object Class | Object Members | System Namespace | String

© 2018 Microsoft