Returns a String that represents the current Object.
Public Overridable Function ToString As String
Dim instance As Object Dim returnValue As String returnValue = instance.ToString()
public virtual string ToString()
public: virtual String^ ToString()
public function ToString() : String
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.
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.
The following code example demonstrates what ToString returns.
Public Class Sample Public Shared Sub Main() ' Displays: "System.Object" Dim o As New Object() Console.WriteLine(o.ToString()) End Sub End Class
using System; public class Sample { public static void Main() { // Prints out: "System.Object" Object o = new Object(); Console.WriteLine (o.ToString()); } }
#using <System.DLL> using namespace System; ref class Sample { private: void Method() { // Prints out: "System.Object" Object^ o = gcnew Object; Console::WriteLine( o->ToString() ); } };
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune