Table of Contents

Class Type

Namespace
System
Assembly
mscorlib.dll

Represents type declarations: class types, interface types, array types, value types, enumeration types, type parameters, generic type definitions, and open or closed constructed generic types.

public abstract class Type : MemberInfo, IReflect
Inheritance
Type
Implements
Inherited Members
Extension Methods

Remarks

Available only in mscorlib build with support for System.Reflection.

Constructors

Type()

protected Type()

Properties

Assembly

Gets the Assembly in which the type is declared. For generic types, gets the Assembly in which the generic type is defined.

public abstract Assembly Assembly { get; }

Property Value

Assembly

An Assembly instance that describes the assembly containing the current type. For generic types, the instance describes the assembly that contains the generic type definition, not the assembly that creates and uses a particular constructed type.

AssemblyQualifiedName

Gets the assembly-qualified name of the type, which includes the name of the assembly from which this Type object was loaded.

public abstract string AssemblyQualifiedName { get; }

Property Value

string

The assembly-qualified name of the Type, which includes the name of the assembly from which the Type was loaded, or null if the current instance represents a generic type parameter.

BaseType

Gets the type from which the current Type directly inherits.

public abstract Type BaseType { get; }

Property Value

Type

The Type from which the current Type directly inherits, or null if the current Type represents the Object class or an interface.

DeclaringType

Gets the type that declares the current nested type or generic type parameter.

public override Type DeclaringType { get; }

Property Value

Type

A Type object representing the enclosing type, if the current type is a nested type; or the generic type definition, if the current type is a type parameter of a generic type; or the type that declares the generic method, if the current type is a type parameter of a generic method; otherwise, null.

FullName

Gets the fully qualified name of the type, including its namespace but not its assembly.

public abstract string FullName { get; }

Property Value

string

The fully qualified name of the type, including its namespace but not its assembly; or null if the current instance represents a generic type parameter, an array type, pointer type, or byref type based on a type parameter, or a generic type that is not a generic type definition but contains unresolved type parameters.

IsAbstract

Gets a value indicating whether the Type is abstract and must be overridden.

public bool IsAbstract { get; }

Property Value

bool

true if the Type is abstract; otherwise, false.

IsArray

Gets a value that indicates whether the type is an array.

public bool IsArray { get; }

Property Value

bool

true if the current type is an array; otherwise, false.

IsClass

Gets a value indicating whether the Type is a class or a delegate; that is, not a value type or interface.

public bool IsClass { get; }

Property Value

bool

true if the Type is a class; otherwise, false.

IsEnum

Gets a value indicating whether the current Type represents an enumeration.

public bool IsEnum { get; }

Property Value

bool

true if the current Type represents an enumeration; otherwise, false.

IsInterface

Gets a value indicating whether the Type is an interface; that is, not a class or a value type.

public bool IsInterface { get; }

Property Value

bool

true if the Type is an interface; otherwise, false.

IsNotPublic

Gets a value indicating whether the Type is not declared public.

public bool IsNotPublic { get; }

Property Value

bool

true if the Type is not declared public and is not a nested type; otherwise, false.

IsPublic

Gets a value indicating whether the Type is declared public.

public bool IsPublic { get; }

Property Value

bool

true if the Type is declared public and is not a nested type; otherwise, false.

IsSerializable

Gets a value indicating whether the Type is serializable.

public bool IsSerializable { get; }

Property Value

bool

true if the Type is serializable; otherwise, false.

IsValueType

Gets a value indicating whether the Type is a value type.

public bool IsValueType { get; }

Property Value

bool

true if the Type is a value type; otherwise, false.

Methods

GetConstructor(Type[])

Searches for a public instance constructor whose parameters match the types in the specified array.

public ConstructorInfo GetConstructor(Type[] types)

Parameters

types Type[]

An array of Type objects representing the number, order, and type of the parameters for the desired constructor.

-or-

An empty array of Type objects, to get a constructor that takes no parameters.Such an empty array is provided by the static field Type.EmptyTypes.

Returns

ConstructorInfo

An object representing the public instance constructor whose parameters match the types in the parameter type array, if found; otherwise, null.

GetConstructors()

Returns all the public constructors defined for the current Type.

public ConstructorInfo[] GetConstructors()

Returns

ConstructorInfo[]

An array of ConstructorInfo objects representing all the public instance constructors defined for the current Type, but not including the type initializer (static constructor). If no public instance constructors are defined for the current Type, or if the current Type represents a type parameter in the definition of a generic type or generic method, an empty array of type ConstructorInfo is returned.

GetElementType()

When overridden in a derived class, returns the Type of the object encompassed or referred to by the current array, pointer or reference type.

public abstract Type GetElementType()

Returns

Type

The Type of the object encompassed or referred to by the current array, pointer, or reference type, or null if the current Type is not an array or a pointer, or is not passed by reference, or represents a generic type or a type parameter in the definition of a generic type or generic method.

GetField(string)

Searches for the public field with the specified name.

public FieldInfo GetField(string name)

Parameters

name string

The string containing the name of the data field to get.

Returns

FieldInfo

An object representing the public field with the specified name, if found; otherwise, null.

GetField(string, BindingFlags)

Searches for the specified field, using the specified binding constraints.

public abstract FieldInfo GetField(string name, BindingFlags bindingAttr)

Parameters

name string

The string containing the name of the data field to get.

bindingAttr BindingFlags

A bitmask comprised of one or more BindingFlags that specify how the search is conducted or Zero, to return null.

Returns

FieldInfo

An object representing the field that matches the specified requirements, if found; otherwise, null.

GetFields()

Returns all the public fields of the current Type.

public FieldInfo[] GetFields()

Returns

FieldInfo[]

An array of FieldInfo objects representing all the public fields defined for the current Type.

-or-

An empty array of type FieldInfo, if no public fields are defined for the current Type.

GetFields(BindingFlags)

When overridden in a derived class, searches for the fields defined for the current Type, using the specified binding constraints.

public abstract FieldInfo[] GetFields(BindingFlags bindingAttr)

Parameters

bindingAttr BindingFlags

A bitmask comprised of one or more BindingFlags that specify how the search is conducted or Zero, to return null.

Returns

FieldInfo[]

An array of FieldInfo objects representing all the public fields defined for the current Type.

-or-

An empty array of type FieldInfo, if no public fields are defined for the current Type.

GetInterfaces()

When overridden in a derived class, gets all the interfaces implemented or inherited by the current Type.

public abstract Type[] GetInterfaces()

Returns

Type[]

An array of Type objects representing all the interfaces implemented or inherited by the current Type.

-or-

An empty array of type Type, if no interfaces are implemented or inherited by the current Type.

GetMethod(string)

Searches for the public method with the specified name.

public MethodInfo GetMethod(string name)

Parameters

name string

The string containing the name of the public method to get.

Returns

MethodInfo

An object that represents the public method with the specified name, if found; otherwise, null.

GetMethod(string, BindingFlags)

Searches for the specified method, using the specified binding constraints.

public MethodInfo GetMethod(string name, BindingFlags bindingAttr)

Parameters

name string

The string containing the name of the method to get.

bindingAttr BindingFlags

A bitmask comprised of one or more BindingFlags that specify how the search is conducted or Zero, to return null.

Returns

MethodInfo

An object representing the method that matches the specified requirements, if found; otherwise, null.

GetMethod(string, Type[])

Searches for the specified public method whose parameters match the specified argument types.

public MethodInfo GetMethod(string name, Type[] types)

Parameters

name string

The string containing the name of the public method to get.

types Type[]

An array of Type objects representing the number, order, and type of the parameters for the desired constructor.

-or-

An empty array of Type objects, to get a constructor that takes no parameters.Such an empty array is provided by the static field Type.EmptyTypes.

Returns

MethodInfo

An object representing the public method whose parameters match the specified argument types, if found; otherwise, null.

GetMethods()

Returns all the public methods of the current Type.

public MethodInfo[] GetMethods()

Returns

MethodInfo[]

An array of MethodInfo objects representing all the public methods defined for the current Type.

-or-

An empty array of type MethodInfo, if no public methods are defined for the current Type.

GetMethods(BindingFlags)

When overridden in a derived class, searches for the methods defined for the current Type, using the specified binding constraints.

public abstract MethodInfo[] GetMethods(BindingFlags bindingAttr)

Parameters

bindingAttr BindingFlags

A bitmask comprised of one or more BindingFlags that specify how the search is conducted or Zero, to return null.

Returns

MethodInfo[]

An array of MethodInfo objects representing all the public methods defined for the current Type.

-or-

An empty array of type MethodInfo, if no public methods are defined for the current Type.

GetType(string)

Gets the Type with the specified name, performing a case-sensitive search.

public static Type GetType(string typeName)

Parameters

typeName string

The assembly-qualified name of the type to get. See AssemblyQualifiedName. If the type is in the currently executing assembly or in Mscorlib.dll, it is sufficient to supply the type name qualified by its namespace.

Returns

Type

The type with the specified name, if found; otherwise, null.

GetTypeFromHandle(RuntimeTypeHandle)

Gets the type referenced by the specified type handle.

public static Type GetTypeFromHandle(RuntimeTypeHandle handle)

Parameters

handle RuntimeTypeHandle

The object that refers to the type.

Returns

Type

The type referenced by the specified RuntimeTypeHandle, or null if the Value property of handle is null.

InvokeMember(string, BindingFlags, Binder, object, object[])

Invokes the specified member, using the specified binding constraints and matching the specified argument list.

public object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args)

Parameters

name string

The string containing the name of the constructor, method, property, or field member to invoke.

-or-

An empty string ("") to invoke the default member.

-or-

For IDispatch members, a string representing the DispID, for example "[DispID=3]".

invokeAttr BindingFlags

A bitmask comprised of one or more BindingFlags that specify how the search is conducted. The access can be one of the BindingFlags such as Public, NonPublic, Private, InvokeMethod, GetField, and so on. The type of lookup need not be specified. If the type of lookup is omitted, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static are used.

binder Binder

An object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.

-or-

A null reference(Nothing in Visual Basic), to use the DefaultBinder.Note that explicitly defining a Binder object may be required for successfully invoking method overloads with variable arguments.

target object

The object on which to invoke the specified member.

args object[]

An array containing the arguments to pass to the member to invoke.

Returns

object

An object representing the return value of the invoked member.

IsInstanceOfType(object)

Determines whether the specified object is an instance of the current Type.

public virtual bool IsInstanceOfType(object o)

Parameters

o object

The object to compare with the current type.

Returns

bool

true if the current Type is in the inheritance hierarchy of the object represented by o, or if the current Type is an interface that o implements. false if neither of these conditions is the case, if o is null, or if the current Type is an open generic type (that is, ContainsGenericParameters returns true).

IsSubclassOf(Type)

Determines whether the current Type derives from the specified Type.

public virtual bool IsSubclassOf(Type c)

Parameters

c Type

The type to compare with the current type.

Returns

bool

true if the current Type derives from c; otherwise, false. This method also returns false if c and the current Type are equal.

ToString()

Returns a String representing the name of the current Type.

public override string ToString()

Returns

string

A String representing the name of the current Type.