System.Object.ToString Method

Returns a string that represents the current object.


public virtual string ToString ()


A string that represents the current object.


object.ToString is the major formatting method in the .NET Framework. It converts an object to its string representation so that it is suitable for display. (For information about formatting support in the .NET Framework, see Formatting Types.)

The default implementation of the object.ToString method returns the fully qualified name of the type of the object, as the following example shows.

code reference: System.Object.ToString#1

Because object is the base class of all reference types in the .NET Framework, this behavior is inherited by reference types that do not override the object.ToString method. The following example illustrates this. It defines a class named Object1 that accepts the default implementation of all object members. Its object.ToString method returns the object's fully qualified type name.

code reference: System.Object.ToString#2

Types commonly override the object.ToString method to return a string that represents the object instance. For example, the base types such as char, int, and string provide object.ToString implementations that return the string form of the value that the object represents. The following example defines a class, Object2, that overrides the object.ToString method to return the type name along with its value.

code reference: System.Object.ToString#3

Notes for the wrt

When you call the object.ToString method on a class in the wrt, it provides the default behavior for classes that don’t override object.ToString. This is part of the support that the .NET Framework provides for the wrt (see .NET Framework Support for Windows Store Apps and Windows Runtime). Classes in the wrt don’t inherit object, and don’t always implement a object.ToString. However, they always appear to have object.ToString, object.Equals(object), and object.GetHashCode methods when you use them in your C# or Visual Basic code, and the .NET Framework provides a default behavior for these methods.

Starting with the net_v451, the common language runtime will use tp:// on a wrt object before falling back to the default implementation of object.ToString.


wrt classes that are written in C# or Visual Basic can override the object.ToString method.

The wrt and the IStringable Interface

Starting with win81, the wrt includes an tp:// interface whose single method, tp://, provides basic formatting support comparable to that provided by object.ToString. To prevent ambiguity, you should not implement tp:// on managed types.

When managed objects are called by native code or by code written in languages such as JavaScript or C++/CX, they appear to implement tp:// The common language runtime will automatically route calls from tp:// to object.ToString in the event tp:// is not implemented on the managed object.


Because the common language runtime auto-implements tp:// for all managed types in win8_appstore_long apps, we recommend that you do not provide your own tp:// implementation. Implementing tp:// may result in unintended behavior when calling ToString from the wrt, C++/CX, or JavaScript.

If you do choose to implement tp:// in a public managed type that is exported in a wrt component, the following restrictions apply:

Note that under a variety of conditions, calls from native code to a managed type that implements tp:// or hides its tp:// implementation can produce unexpected behavior.


The following example outputs the textual description of the value of an object of type object to the console.

C# Example

using System;

class MyClass {
   static void Main() {
      object o = new object();
      Console.WriteLine (o.ToString());

The output is



Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0,,