C# Type Name

Description

Type Name gets the name of the current member.

Syntax

Type.Name has the following syntax.


public abstract string Name { get; }

Example

This example lists the Name and DeclaringType property of each member of the specified class.


//from  w w  w  . j a  v a  2s.  co  m
using System;
using System.Reflection;

class Mymemberinfo
{
    public static int Main()
    {
        Type MyType = Type.GetType("System.Empty");
        MemberInfo[] Mymemberinfoarray = MyType.GetMembers();

        Console.Write("{0}.", MyType.FullName);

        foreach (MemberInfo Mymemberinfo in Mymemberinfoarray)
        {
            Console.Write("\n" + Mymemberinfo.Name
                + " declaring type - " +
                Mymemberinfo.DeclaringType);
        }

        return 0;
    }
}

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