C# Type ToString

Description

Type ToString returns a String representing the name of the current Type.

Syntax

Type.ToString has the following syntax.


public override string ToString()

Returns

Type.ToString method returns A String representing the name of the current Type.

Example

This following example demonstrates a use of the Namespace and Module properties and the ToString method of Type.


using System;//  w w  w  .j  ava2 s.  c  o  m

namespace MyNamespace
{
    class MyClass
    {
    }
}

public class Example
{
    public static void Main()
    {
         Type myType = typeof(MyNamespace.MyClass);
         Console.WriteLine("   Fully qualified name: {0}.", myType.ToString());
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version