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.

ValueType.ToString Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Returns the fully qualified type name of this instance.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

override ToString : unit -> string

Return Value

Type: System.String

The fully qualified type name.

The ValueType.ToString method overrides the Object.ToString method and provides the default implementation of the ToString method for value types. (Value types are types defined by the struct keyword in C#, and by the Structure...End Structure construct in Visual Basic.) Functionally, however, the implementation is that same as that of Object.ToString: the method returns the fully qualified type name.

Value types defined by the struct keyword in C# and the Structure...End Structure construct in Visual Basic typically override the ValueType.ToString method to provide a more meaningful string representation of the value type. The following example illustrates the difference. It defines two value types, EmployeeA and EmployeeB, creates an instance of each, and calls its ToString method. Because the EmployeeA structure does not override the ValueType.ToString method, it displays only the fully qualified type name. The EmployeeB.ToString method, on the other hand, provides meaningful information about the object.

No code example is currently available or this language may not be supported.

Note that, although enumeration types are also value types, they derive from the Enum class, which overrides ValueType.ToString.

When you call the ToString method on a Windows Runtime structure, it provides the default behavior for value types that don’t override ToString. This is part of the support that the .NET Framework provides for the Windows Runtime (see .NET Framework Support for Windows Store Apps and Windows Runtime). Windows Runtime structures can’t override ToString, even if they’re written with C# or Visual Basic, because they can’t have methods. (In addition, structures in the Windows Runtime itself don’t inherit ValueType.) However, they appear to have ToString, Equals, and GetHashCode methods when you use them in your C# or Visual Basic code, and the .NET Framework provides the default behavior for these methods.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2018 Microsoft