Type.ToString Method
Returns a String representing the name of the current Type.
Assembly: mscorlib (in mscorlib.dll)
This method returns the fully qualified common language runtime namespace and name for all primitive types. For example, the C# instruction, (long)0.Type().ToString() returns "System.Int64" instead of merely "Int64".
If the current Type represents a generic type, the type and its type arguments are qualified by namespace and by nested type, but not by assembly. If the current Type represents a type parameter in the definition of a generic type or generic method, this method returns the unqualified name of the type parameter.
This following example demonstrates a use of the Namespace and Module properties and the ToString method of Type.
Imports System Imports Microsoft.VisualBasic Namespace MyNamespace Class [MyClass] End Class '[MyClass] End Namespace 'MyNamespace Public Class Type_ToString_3 Public Shared Sub Main() Try Dim myType As Type = GetType(MyNamespace.MyClass) Console.WriteLine(ControlChars.NewLine + "Printing the details of {0}." + ControlChars.NewLine, myType) ' Get the namespace of the class Type_ToString_3. Console.WriteLine("Namespace: {0}.", myType.Namespace) ' Get the name of the module. Console.WriteLine("Module: {0}.", myType.Module) ' Get the fully qualified common language runtime namespace. Console.WriteLine("Fully qualified type: {0}.", myType.ToString()) Catch e As Exception Console.WriteLine("Exception: " + e.Message.ToString()) End Try End Sub 'Main End Class 'Type_ToString_3
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.