System.Type Class

public abstract class Type : Object

Base Types

Object
  MemberInfo (excluded)
    Type

Assembly

mscorlib

Library

BCL

Summary

Provides information about a type.

Description

The Type class is abstract, as is the MemberInfo class and its subclasses FieldInfo, PropertyInfo, MethodBase, and EventInfo. ConstructorInfo and MethodInfo are subclasses of MethodBase. The runtime provides non-public implementations of these classes. [Note: For example, System.Type.GetMethod(System.String,System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[]) is typed as returning a MethodInfo object. The returned object is actually an instance of the non-public runtime type that implements MethodInfo .]

A conforming CLI program which is written to run on only the Kernel profile cannot subclass Type. [Note: This only applies to conforming programs not conforming implementations.]

A Type object that represents a type is unique; that is, two Type object references refer to the same object if and only if they represent the same type. This allows for comparison of Type objects using reference equality.

[Note: An instance of Type can represent any one of the following types:

The following table shows what members of a base class are returned by the methods that return members of types, such as System.Type.GetConstructor(System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[]) and System.Type.GetMethod(System.String,System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[]).

Member TypeStatic
ConstructorNo
FieldNo
EventNot applicable
MethodNo
Nested TypeNo
PropertyNot applicable

For reflection, properties and events are hide-by-name-and-signature. If a property has both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and the setter on the base class will not be accessible.

]

The description of System.Type.IsGenericType contains definitions for some important terms.

See Also

System Namespace

Members

Type Constructors

Type Constructor

Type Methods

Type.Equals Method
Type.GetArrayRank Method
Type.GetAttributeFlagsImpl Method
Type.GetConstructor(System.Reflection.BindingFlags, System.Reflection.Binder, System.Type[], System.Reflection.ParameterModifier[]) Method
Type.GetConstructor(System.Type[]) Method
Type.GetConstructors() Method
Type.GetConstructors(System.Reflection.BindingFlags) Method
Type.GetDefaultMembers Method
Type.GetElementType Method
Type.GetEvent(System.String) Method
Type.GetEvent(System.String, System.Reflection.BindingFlags) Method
Type.GetEvents() Method
Type.GetEvents(System.Reflection.BindingFlags) Method
Type.GetField(System.String, System.Reflection.BindingFlags) Method
Type.GetField(System.String) Method
Type.GetFields() Method
Type.GetFields(System.Reflection.BindingFlags) Method
Type.GetGenericArguments Method
Type.GetGenericParameterConstraints Method
Type.GetGenericTypeDefinition Method
Type.GetHashCode Method
Type.GetInterface(System.String, bool) Method
Type.GetInterface(System.String) Method
Type.GetInterfaces Method
Type.GetMember(System.String, System.Reflection.BindingFlags) Method
Type.GetMember(System.String) Method
Type.GetMembers(System.Reflection.BindingFlags) Method
Type.GetMembers() Method
Type.GetMethod(System.String, System.Reflection.BindingFlags, System.Reflection.Binder, System.Type[], System.Reflection.ParameterModifier[]) Method
Type.GetMethod(System.String, System.Reflection.BindingFlags) Method
Type.GetMethod(System.String) Method
Type.GetMethod(System.String, System.Type[]) Method
Type.GetMethod(System.String, System.Type[], System.Reflection.ParameterModifier[]) Method
Type.GetMethods(System.Reflection.BindingFlags) Method
Type.GetMethods() Method
Type.GetNestedType(System.String) Method
Type.GetNestedType(System.String, System.Reflection.BindingFlags) Method
Type.GetNestedTypes() Method
Type.GetNestedTypes(System.Reflection.BindingFlags) Method
Type.GetProperties(System.Reflection.BindingFlags) Method
Type.GetProperties() Method
Type.GetProperty(System.String, System.Type, System.Type[]) Method
Type.GetProperty(System.String, System.Type[]) Method
Type.GetProperty(System.String, System.Type) Method
Type.GetProperty(System.String) Method
Type.GetProperty(System.String, System.Reflection.BindingFlags) Method
Type.GetProperty(System.String, System.Reflection.BindingFlags, System.Reflection.Binder, System.Type, System.Type[], System.Reflection.ParameterModifier[]) Method
Type.GetPropertyImpl Method
Type.GetType(System.String, bool, bool) Method
Type.GetType(System.String, bool) Method
Type.GetType(System.String) Method
Type.GetTypeArray Method
Type.GetTypeFromHandle Method
Type.GetTypeHandle Method
Type.HasElementTypeImpl Method
Type.InvokeMember(System.String, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object, System.Object[], System.Globalization.CultureInfo) Method
Type.InvokeMember(System.String, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object, System.Object[]) Method
Type.InvokeMember(System.String, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object, System.Object[], System.Reflection.ParameterModifier[], System.Globalization.CultureInfo, System.String[]) Method
Type.IsArrayImpl Method
Type.IsAssignableFrom Method
Type.IsByRefImpl Method
Type.IsCOMObjectImpl Method
Type.IsInstanceOfType Method
Type.IsPointerImpl Method
Type.IsPrimitiveImpl Method
Type.IsSubclassOf Method
Type.MakeArrayType() Method
Type.MakeArrayType(int) Method
Type.MakeByRefType Method
Type.MakeGenericType Method
Type.MakePointerType Method
Type.ToString Method

Type Fields

Type.Delimiter Field
Type.EmptyTypes Field
Type.Missing Field

Type Properties

Type.Assembly Property
Type.AssemblyQualifiedName Property
Type.Attributes Property
Type.BaseType Property
Type.ContainsGenericParameters Property
Type.DeclaringMethod Property
Type.DeclaringType Property
Type.DefaultBinder Property
Type.FullName Property
Type.GenericParameterAttributes Property
Type.GenericParameterPosition Property
Type.HasElementType Property
Type.IsAbstract Property
Type.IsAnsiClass Property
Type.IsArray Property
Type.IsAutoClass Property
Type.IsAutoLayout Property
Type.IsByRef Property
Type.IsClass Property
Type.IsEnum Property
Type.IsExplicitLayout Property
Type.IsGenericParameter Property
Type.IsGenericType Property
Type.IsGenericTypeDefinition Property
Type.IsImport Property
Type.IsInterface Property
Type.IsLayoutSequential Property
Type.IsMarshalByRef Property
Type.IsNestedAssembly Property
Type.IsNestedFamANDAssem Property
Type.IsNestedFamORAssem Property
Type.IsNestedFamily Property
Type.IsNestedPrivate Property
Type.IsNestedPublic Property
Type.IsNotPublic Property
Type.IsPointer Property
Type.IsPrimitive Property
Type.IsPublic Property
Type.IsSealed Property
Type.IsSpecialName Property
Type.IsUnicodeClass Property
Type.IsValueType Property
Type.Module Property
Type.Namespace Property
Type.ReflectedType Property
Type.TypeHandle Property
Type.TypeInitializer Property
Type.UnderlyingSystemType Property


Type Constructor

protected Type();

Summary

Constructs a new instance of the Type class.

Library

Reflection

See Also

System.Type Class, System Namespace

Type.Equals Method

public bool Equals(Type o);

Summary

Determines if the underlying system type of the current Type is the same as the underlying system type of the specified Type.

Parameters

o
The Type whose underlying system type is to be compared with the underlying system type of the current Type.

Return Value

true if the underlying system type of o is the same as the underlying system type of the current Type; otherwise, false .

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetArrayRank Method

public virtual int GetArrayRank();

Summary

Returns the number of dimensions in the current Type.

Return Value

A Int32 containing the number of dimensions in the current Type.

Exceptions

Exception TypeCondition
ArgumentExceptionThe current Type is not an array.

See Also

System.Type Class, System Namespace

Type.GetAttributeFlagsImpl Method

protected abstract TypeAttributes GetAttributeFlagsImpl();

Summary

When overridden in a derived type implements the System.Type.Attributes property and returns the attributes specified for the type represented by the current instance.

Return Value

A TypeAttributes value that signifies the attributes of the type represented by the current instance.

Description

[Behaviors: This property is read-only.

This method returns a TypeAttributes value that indicates the attributes set in the metadata of the type represented by the current instance.

]

[Usage: Use this property to determine the visibility, semantics, and layout format of the type represented by the current instance. Also use this property to determine if the type represented by the current instance has a special name.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetConstructor(System.Reflection.BindingFlags, System.Reflection.Binder, System.Type[], System.Reflection.ParameterModifier[]) Method

public ConstructorInfo GetConstructor(BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers);

Summary

Returns a constructor defined in the type represented by the current instance. The parameters of the constructor match the specified argument types and modifiers, under the specified binding constraints.

Parameters

bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null.

binder
A Binder object that defines a set of properties and enables the binding, coercion of argument types, and invocation of members using reflection. Specify null to use the System.Type.DefaultBinder .

types
An array of Type objects. The elements in the array are of the same number, in the same order, and represent the same types as the parameters for the constructor to be returned.

modifiers
The only defined value for this parameter is null .

Return Value

A ConstructorInfo object that reflects the constructor that matches the specified criteria. If an exact match does not exist, binder will attempt to coerce the parameter types specified in types to select a match. If binder is unable to select a match, returns null . If the type represented by the current instance is contained in a loaded assembly, the constructor that matches the specified criteria is not public, and the caller does not have sufficient permissions, returns null .

Exceptions

Exception TypeCondition
ArgumentNullExceptiontypes is null , or at least one of the elements in types is null .

ArgumentExceptiontypes has more than one dimension.

Description

The following BindingFlags are used to define which constructors to include in the search:

[Note: For more information, see BindingFlags.]

If the current instance represents a generic type, this method returns the ConstructorInfo with the type parameters replaced by the appropriate type arguments. If the current instance represents an unassigned type parameter of a generic type or method, this method always returns null .

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetConstructor(System.Type[]) Method

public ConstructorInfo GetConstructor(Type[] types);

Summary

Returns a public instance constructor defined in the type represented by the current instance. The parameters of the constructor match the specified argument types.

Parameters

types
An array of Type objects. The elements in the array are of the same number, in the same order, and represent the same types as the parameters for the constructor to be returned. Specify System.Type.EmptyTypes to obtain a constructor that takes no parameters.

Return Value

A ConstructorInfo object representing the public instance constructor whose parameters match exactly the types in types , if found; otherwise, null . If the type represented by the current instance is contained in a loaded assembly, the constructor that matches the specified criteria is not public, and the caller does not have sufficient permissions, returns null .

If the current instance represents a generic type, this method returns the ConstructorInfo with the type parameters replaced by the appropriate type arguments. If the current instance represents an unassigned type parameter of a generic type or method, this method always returns null .

Exceptions

Exception TypeCondition
ArgumentNullExceptiontypes is null , or at least one of the elements in types is null .

ArgumentExceptiontypes has more than one dimension.

Description

This version of System.Type.GetConstructor(System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[]) is equivalent to System.Type.GetConstructor(System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[])(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null , types, null ).

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetConstructors() Method

public ConstructorInfo[] GetConstructors();

Summary

Returns an array of the public constructors defined in the type represented by the current instance.

Return Value

An array of ConstructorInfo objects that reflect the public constructors defined in the type represented by the current instance. If no public constructors are defined in the type represented by the current instance, or if the current instance represents an unassigned type parameter of a generic type or method, returns an empty array.

If the current instance represents a generic type, this method returns the ConstructorInfo objects with the type parameters replaced by the appropriate type arguments.

If the current instance represents a generic type parameter, the System.Type.GetConstructorsmethod returns an empty array.

Description

This version of System.Type.GetConstructors is equivalent to System.Type.GetConstructors(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetConstructors(System.Reflection.BindingFlags) Method

public abstract ConstructorInfo[] GetConstructors(BindingFlags bindingAttr);

Summary

Returns an array of constructors defined in the type represented by the current instance, under the specified binding constraints.

Parameters

bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null .

Return Value

An array of ConstructorInfo objects that reflect the constructors that are defined in the type represented by the current instance and match the constraints of bindingAttr. If System.Reflection.BindingFlags.NonPublic and System.Reflection.BindingFlags.Static are specified, this array includes the type initializer if it is defined. If no constructors meeting the constraints of bindingAttr are defined in the type represented by the current instance, or if the current instance represents an unassigned type parameter of a generic type or method, returns an empty array. If the type represented by the current instance is contained in a loaded assembly, the constructors that match the specified criteria are not public, and the caller does not have sufficient permission, returns null .

If the current instance represents a generic type, this method returns the ConstructorInfo objects with the type parameters replaced by the appropriate type arguments.

If the current instance represents a generic type parameter, the System.Type.GetConstructorsmethod returns an empty array.

Description

The following BindingFlags are used to define which constructors to include in the search:

[Note: For more information, see BindingFlags.]

[Behaviors: As described above.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetDefaultMembers Method

public virtual MemberInfo[] GetDefaultMembers();

Summary

Returns an array of MemberInfo objects that reflect the default members defined in the type represented by the current instance.

Return Value

An array of MemberInfo objects reflecting the default members of the type represented by the current instance. If the type represented by the current instance does not have any default members, returns an empty array.

Description

If the current instance represents a generic type, this method returns the MemberInfo objects with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the members of the class constraint, or the members of Object if there is no class constraint; the members of all interface constraints; and the members of any interfaces inherited from class or interface constraints.

[Behaviors: The members returned by this method have the DefaultMemberAttribute attribute.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetElementType Method

public abstract Type GetElementType();

Summary

Returns the element type of the current Type .

Return Value

A Type that represents the type used to create the current instance if the current instance represents an array, pointer, or an argument passed by reference. Otherwise, returns null if the current instance is not an array or a pointer, or is not passed by reference, or represents a generic type or a type parameter of a generic type or method.

Example

The following example demonstrates the System.Type.GetElementType method.

using System;
class TestType {
 public static void Main() {
 int[] array = {1,2,3};
 Type t = array.GetType();
 Type t2 = t.GetElementType();
 Console.WriteLine("{0} element type is {1}",array, t2.ToString());

 TestType newMe = new TestType();
 t = newMe.GetType();
 t2 = t.GetElementType();
 Console.WriteLine("{0} element type is {1}", newMe, t2==null? "null" : t2.ToString());
 }
}
The output is

System.Int32[] element type is System.Int32

TestType element type is null

See Also

System.Type Class, System Namespace

Type.GetEvent(System.String) Method

public EventInfo GetEvent(string name);

Summary

Returns a EventInfo object reflecting the public event that has the specified name and is defined in the type represented by the current instance.

Parameters

name
A String containing the name of the public event to be returned.

Return Value

A EventInfo object reflecting the public event that is named name and is defined in the type represented by the current instance, if found; otherwise, null .

If the current instance represents a generic type, this method returns the EventInfo with the type parameters replaced by the appropriate type arguments.

Exceptions

Exception TypeCondition
ArgumentNullExceptionname is null .

Description

This version of System.Type.GetEvent(System.String) is equivalent to System.Type.GetEvent(System.String)( name, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public ).

The search for name is case-sensitive.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the events of the class constraint; the events of all interface constraints; and the events of any interfaces inherited from class or interface constraints.

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetEvent(System.String, System.Reflection.BindingFlags) Method

public abstract EventInfo GetEvent(string name, BindingFlags bindingAttr);

Summary

Returns a EventInfo object reflecting the event that has the specified name, is defined in the type represented by the current instance, and matches the specified binding constraints.

Parameters

name
A String containing the name of the event to be returned.
bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null.

Return Value

A EventInfo object reflecting the event that is named name, is defined in the type represented by the current instance, and matches the constraints of bindingAttr. If an event matching these criteria is not found, returns null . If the event is not public, the current instance represents a type from a loaded assembly, and the caller does not have sufficient permission, returns null .

If the current instance represents a generic type, this method returns the EventInfo with the type parameters replaced by the appropriate type arguments.

Exceptions

Exception TypeCondition
ArgumentNullExceptionname is null .

Description

The following BindingFlags are used to define which events to include in the search:

The following BindingFlags value can be used to change how the search works:

[Note: For more information, see BindingFlags.]

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the events of the class constraint; the events of all interface constraints; and the events of any interfaces inherited from class or interface constraints.

[Behaviors: As described above.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetEvents() Method

public virtual EventInfo[] GetEvents();

Summary

Returns an array of EventInfo objects that reflect the public events defined in the type represented by the current instance.

Return Value

An array of EventInfo objects that reflect the public events defined in the type represented by the current instance. If no public events are defined in the type represented by the current instance, returns an empty array.

If the current instance represents a generic type, this method returns the EventInfo objects with the type parameters replaced by the appropriate type arguments.

Description

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the events of the class constraint; the events of all interface constraints; and the events of any interfaces inherited from class or interface constraints.

[Behaviors: As described above.]

[Default: This version of System.Type.GetEvents is equivalent to System.Type.GetEvents(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance).]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetEvents(System.Reflection.BindingFlags) Method

public abstract EventInfo[] GetEvents(BindingFlags bindingAttr);

Summary

Returns an array of EventInfo objects that reflect the events that are defined in the type represented by the current instance and match the specified binding constraints.

Parameters

bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null.

Return Value

An array of EventInfo objects that reflect the events that are defined in the type represented by the current instance and match the constraints of bindingAttr . If no events match these constraints, returns an empty array. If the type reflected by the current instance is from a loaded assembly and the caller does not have permission to reflect on non-public objects in loaded assemblies, returns only public events.

If the current instance represents a generic type, this method returns the EventInfo objects with the type parameters replaced by the appropriate type arguments.

Description

The following BindingFlags are used to define which events to include in the search:

[Note: For more information, see BindingFlags.]

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the events of the class constraint; the events of all interface constraints; and the events of any interfaces inherited from class or interface constraints.

[Behaviors: As described above.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetField(System.String, System.Reflection.BindingFlags) Method

public abstract FieldInfo GetField(string name, BindingFlags bindingAttr);

Summary

Returns a FieldInfo object reflecting the field that has the specified name, is defined in the type represented by the current instance, and matches the specified binding constraints.

Parameters

name
A String containing the name of the field to be returned.
bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null .

Return Value

A FieldInfo object reflecting the field that is named name, is defined in the type represented by the current instance, and matches the constraints of bindingAttr. If a field matching these criteria cannot be found, returns null . If the field is not public, the current type is from a loaded assembly, and the caller does not have sufficient permission, returns null .

If the current instance represents a generic type, this method returns the FieldInfo with the type parameters replaced by the appropriate type arguments.

Exceptions

Exception TypeCondition
ArgumentNullExceptionname is null .

Description

The following BindingFlags are used to define which fields to include in the search:

The following BindingFlags values can be used to change how the search works:

[Note: For more information, see BindingFlags.]

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the fields of the class constraint; the fields of all interface constraints; and the fields of any interfaces inherited from class or interface constraints.

[Behaviors: As described above.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetField(System.String) Method

public FieldInfo GetField(string name);

Summary

Returns a FieldInfo object reflecting the field that has the specified name and is defined in the type represented by the current instance.

Parameters

name
A String containing the name of the field to be returned.

Return Value

A FieldInfo object reflecting the field that is named name and is defined in the type represented by the current instance, if found; otherwise, null . If the selected field is non-public, the type represented by the current instance is from a loaded assembly and the caller does not have sufficient permission to reflect on non-public objects in loaded assemblies, returns null .

If the current instance represents a generic type, this method returns the FieldInfo with the type parameters replaced by the appropriate type arguments.

Exceptions

Exception TypeCondition
ArgumentNullExceptionname is null .

Description

The search for name is case-sensitive.

This version of System.Type.GetField(System.String,System.Reflection.BindingFlags) is equivalent to System.Type.GetField(System.String,System.Reflection.BindingFlags)( name, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance ).

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the fields of the class constraint; the fields of all interface constraints; and the fields of any interfaces inherited from class or interface constraints.

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetFields() Method

public FieldInfo[] GetFields();

Summary

Returns an array of FieldInfo objects that reflect the public fields defined in the type represented by the current instance.

Return Value

An array of FieldInfo objects that reflect the public fields defined in the type represented by the current instance. If no public fields are defined in the type represented by the current instance, returns an empty array.

If the current instance represents a generic type, this method returns the FieldInfo objects with the type parameters replaced by the appropriate type arguments.

Description

This version of System.Type.GetFields is equivalent to System.Type.GetFields( System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public ).

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the fields of the class constraint; the fields of all interface constraints; and the fields of any interfaces inherited from class or interface constraints.

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetFields(System.Reflection.BindingFlags) Method

public abstract FieldInfo[] GetFields(BindingFlags bindingAttr);

Summary

Returns an array of FieldInfo objects that reflect the fields that are defined in the type represented by the current instance and match the specified binding constraints.

Parameters

bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null .

Return Value

An array of FieldInfo objects that reflect the fields that are defined in the type represented by the current instance and match the constraints of bindingAttr . If no fields match these constraints, returns an empty array. If the type represented by the current instance is from a loaded assembly and the caller does not have sufficient permission to reflect on non-public objects in loaded assemblies, returns only public fields.

If the current instance represents a generic type, this method returns the FieldInfo objects with the type parameters replaced by the appropriate type arguments.

Description

The following BindingFlags are used to define which fields to include in the search:

The following BindingFlags values can be used to change how the search works:

[Note: For more information, see BindingFlags.]

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the fields of the class constraint; the fields of all interface constraints; and the fields of any interfaces inherited from class or interface constraints.

[Behaviors: As described above.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetGenericArguments Method

public virtual Type[] GetGenericArguments()

Summary

Returns an array of Type objects that represent the type arguments of a generic type or the type parameters of a generic type definition.

Return Value

An array of Type objects that represent the type arguments of a generic type or the type parameters of a generic type definition. Returns an empty array if the current type is not a generic type. The array elements are returned in the order in which they appear in the list of type arguments for the generic type.

Description

If the current type is a closed constructed type, the array returned by the System.Type.GetGenericArguments method contains the type arguments that are bound to the type parameters. If the current type is a generic type definition, the array contains the type parameters. If the current type is an open constructed type in which some of the type parameters are bound to specific types, the array contains both type arguments and type parameters.

For a list of the invariant conditions for terms used in generic reflection, see the System.Type.IsGenericType property description.

Example

For an example of using this method, see the example for System.Type.GenericParameterPosition.

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetGenericParameterConstraints Method

public virtual Type[] GetGenericParameterConstraints()

Summary

Returns an array of Type objects that represent the type constraints on the current generic type parameter.

Return Value

An array of Type objects that represent the type constraints on the current generic type parameter.

Exceptions

Exception TypeCondition
InvalidOperationExceptionThe current Type object is not a generic type parameter. That is, the System.Type.IsGenericParameter property returns false .

Description

Each constraint on a generic type parameter is expressed as a Type object. The first element of the array is the class constraint, if any. If a type parameter has no class constraint and no interface constraints, an empty array of Type is returned for that type parameter. Use System.Reflection.GenericParameterAttributes to get the special constraints.

For a list of the invariant conditions for terms used in generic reflection, see the System.Type.IsGenericType property description.

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetGenericTypeDefinition Method

public virtual Type GetGenericTypeDefinition()

Summary

Returns a Type object that represents a generic type from which the current type can be constructed.

Return Value

A Type object representing a generic type from which the current type can be constructed.

Exceptions

Exception TypeCondition
InvalidOperationExceptionThe current type is not a generic type. That is, System.Type.HasGenericArguments returns false .

Description

If two constructed types are created from the same generic type definition, the System.Type.GetGenericTypeDefinition method returns the same Type object for both types.

If you call System.Type.GetGenericTypeDefinition on a Type object that already represents a generic type definition, it returns the current Type.

[Note: An array type whose element type is a generic type is not itself generic. Use System.Type.IsGenericType to determine whether a type is generic before calling System.Type.GetGenericTypeDefinition.]

For a list of the invariant conditions for terms used in generic reflection, see the System.Type.IsGenericType property description.

Example

For an example of using this method, see the example for System.Type.MakeGenericType.

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetHashCode Method

public override int GetHashCode();

Summary

Generates a hash code for the current instance.

Return Value

A Int32 containing the hash code for this instance.

Description

The algorithm used to generate the hash code is unspecified.

[Note: This method overrides System.Object.GetHashCode .]

See Also

System.Type Class, System Namespace

Type.GetInterface(System.String, bool) Method

public abstract Type GetInterface(string name, bool ignoreCase);

Summary

Returns the specified interface, specifying whether to do a case-sensitive search.

Parameters

name
A String containing the name of the interface to return.
ignoreCase
A Boolean where true indicates that the name search is to be done case-insensitively, and false performs a case-sensitive search.

Return Value

A Type object representing the interface with the specified name, implemented or inherited by the type represented by the instance, if found; otherwise, null .

Exceptions

Exception TypeCondition
ArgumentNullExceptionname is null .
AmbiguousMatchExceptionThe current instance represents a type that implements the same generic interface with different type arguments.

Description

If the current instance represents a generic type, this method returns the Type with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the interface constraints and any interfaces inherited from class or interface constraints.

[Note: The name parameter cannot include type arguments.]

[Note: Even with the introduction of generics, this method continues to return only non-generic members. To get the generic ones, one must call System.Type.GetInterfaces, and filter them out.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetInterface(System.String) Method

public Type GetInterface(string name);

Summary

Searches for the interface with the specified name.

Parameters

name
A String containing the name of the interface to get.

Return Value

A Type object representing the interface with the specified name, implemented or inherited by the current Type, if found; otherwise, null .

Exceptions

Exception TypeCondition
ArgumentNullExceptionname is null .
AmbiguousMatchExceptionThe current instance represents a type that implements the same generic interface with different type arguments.

Description

The search for name is case-sensitive.

If the current instance represents a generic type, this method returns the Type with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the interface constraints and any interfaces inherited from class or interface constraints.

[Note: The name parameter cannot include type arguments.]

[Note: Even with the introduction of generics, this method continues to return only non-generic members. To get the generic ones, one must call System.Type.GetInterfaces, and filter them out.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetInterfaces Method

public abstract Type[] GetInterfaces();

Summary

Returns all interfaces implemented or inherited by the type represented by the current instance.

Return Value

An array of Type objects representing the interfaces implemented or inherited by the type represented by the current instance. If no interfaces are found, returns an empty Type array.

Description

If the current instance represents a generic type, this method returns the Type objects with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the interface constraints and any interfaces inherited from class or interface constraints.

[Note: Even with the introduction of generics, the overloads of System.Type.GetInterface continue to return only non-generic members. To get the generic ones, one must call System.Type.GetInterfaces, and filter them out.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetMember(System.String, System.Reflection.BindingFlags) Method

public virtual MemberInfo[] GetMember(string name, BindingFlags bindingAttr);

Summary

Returns an array of MemberInfo objects that reflect the members defined in the type represented by the current instance that have the specified name and match the specified binding constraints.

Parameters

name
A String containing the name of the member to be returned.
bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null .

Return Value

An array of MemberInfo objects that reflect the members named name, are defined in the type represented by the current instance and match the constraints of bindingAttr . If no members match these constraints, returns an empty array. If the selected member is non-public, the type reflected by the current instance is from a loaded assembly and the caller does not have sufficient permission to reflect on non-public objects in loaded assemblies, returns null .

Exceptions

Exception TypeCondition
ArgumentNullExceptionname is null .

Description

The following BindingFlags are used to define which members to include in the search:

The following BindingFlags values can be used to change how the search works:

[Note: For more information, see BindingFlags.]

If the current instance represents a generic type, this method returns the MemberInfo with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the members of the class constraint, or the members of Object if there is no class constraint; the members of all interface constraints; and the members of any interfaces inherited from class or interface constraints.

[Note: The name parameter cannot include type arguments.]

[Behaviors: As described above.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetMember(System.String) Method

public MemberInfo[] GetMember(string name);

Summary

Returns an array of MemberInfo objects that reflect the public members that have the specified name and are defined in the type represented by the current instance.

Parameters

name
A String containing the name of the members to be returned.

Return Value

An array of MemberInfo objects that reflect the public members that are named name and are defined in the type represented by the current instance. If no public members with the specified name are defined in the type represented by the current instance, returns an empty array.

Exceptions

Exception TypeCondition
ArgumentNullExceptionname is null .

Description

This version of System.Type.GetMember(System.String) is equivalent to System.Type.GetMember(System.String)( name, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public ).

The search for name is case-sensitive.

If the current instance represents a generic type, this method returns the MemberInfo with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the members of the class constraint, or the members of Object if there is no class constraint; the members of all interface constraints; and the members of any interfaces inherited from class or interface constraints.

[Note: The name parameter cannot include type arguments.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetMembers(System.Reflection.BindingFlags) Method

public abstract MemberInfo[] GetMembers(BindingFlags bindingAttr);

Summary

Returns an array of MemberInfo objects that reflect the members that are defined in the type represented by the current instance and match the specified binding constraints.

Parameters

bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null .

Return Value

An array of MemberInfo objects that reflect the members defined in the type represented by the current instance that match the constraints of bindingAttr . If no members match these constraints, returns an empty array. If the type represented by the current instance is from a loaded assembly and the caller does not have sufficient permission to reflect on non-public objects in loaded assemblies, returns only public members.

Description

The following BindingFlags are used to define which members to include in the search:

The following BindingFlags values can be used to change how the search works:

[Note: For more information, see BindingFlags.]

If the current instance represents a generic type, this method returns the MemberInfo objects with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the members of the class constraint, or the members of Object if there is no class constraint; the members of all interface constraints; and the members of any interfaces inherited from class or interface constraints.

[Behaviors: As described above.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetMembers() Method

public MemberInfo[] GetMembers();

Summary

Returns an array of MemberInfo objects that reflect the public members defined in the type represented by the current instance.

Return Value

An array of MemberInfo objects that reflect the public members defined in the type represented by the current instance. If no public members are defined in the type represented by the current instance, returns an empty array.

Description

This version of System.Type.GetMembers is equivalent to System.Type.GetMembers(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance).

If the current instance represents a generic type, this method returns the MemberInfo objects with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the members of the class constraint, or the members of Object if there is no class constraint; the members of all interface constraints; and the members of any interfaces inherited from class or interface constraints.

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetMethod(System.String, System.Reflection.BindingFlags, System.Reflection.Binder, System.Type[], System.Reflection.ParameterModifier[]) Method

public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers);

Summary

Returns a MethodInfo object that reflects the method that matches the specified criteria and is defined in the type represented by the current instance.

Parameters

name
A String containing the name of the method to be returned.
bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null .

binder
A Binder object that defines a set of properties and enables the binding, coercion of argument types, and invocation of members using reflection. Specify null to use the System.Type.DefaultBinder .

types
An array of Type objects. The elements in the array are of the same number, in the same order, and represent the same types as the parameters for the method to be returned.

modifiers
The only defined value for this parameter is null .

Return Value

A MethodInfo object that reflects the method defined in the type represented by the current instance that matches the specified criteria. If no method matching the specified criteria is found, returns null . If the selected method is non-public, the type reflected by the current instance is from a loaded assembly, and the caller does not have permission to reflect on non-public objects in loaded assemblies, returns null .

Exceptions

Exception TypeCondition
AmbiguousMatchExceptionMore than one method matching the specified criteria was found.
ArgumentNullExceptionname or types is null .

-or-

At least one of the elements in types is null .

ArgumentExceptiontypes has more than one dimension.

Description

The following BindingFlags are used to define which members to include in the search:

The following BindingFlags values can be used to change how the search works:

[Note: For more information, see BindingFlags.]

If the current instance represents a generic type, this method returns the MethodInfo with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the methods of the class constraint, or the methods of Object if there is no class constraint; the methods of all interface constraints; and the methods of any interfaces inherited from class or interface constraints.

[Note: The name parameter cannot include type arguments.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetMethod(System.String, System.Reflection.BindingFlags) Method

public MethodInfo GetMethod(string name, BindingFlags bindingAttr);

Summary

Returns a MethodInfo object that reflects the method that has the specified name and is defined in the type represented by the current instance.

Parameters

name
A String containing the name of the method to be returned.
bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null .

Return Value

A MethodInfo object that reflects the method that is defined in the type represented by the current instance and matches the specified criteria, if found; otherwise, null .

Exceptions

Exception TypeCondition
AmbiguousMatchExceptionMore than one method matching the specified criteria was found.
ArgumentNullExceptionname is null .

Description

The following BindingFlags are used to define which members to include in the search:

The following BindingFlags values can be used to change how the search works:

[Note: For more information, see BindingFlags.]

This version of System.Type.GetMethod(System.String,System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[]) is equivalent to System.Type.GetMethod(System.String,System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[])(name, bindingAttr , null , null , null ).

If the current instance represents a generic type, this method returns the MethodInfo with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the methods of the class constraint, or the methods of Object if there is no class constraint; the methods of all interface constraints; and the methods of any interfaces inherited from class or interface constraints.

[Note: The name parameter cannot include type arguments.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetMethod(System.String) Method

public MethodInfo GetMethod(string name);

Summary

Returns a MethodInfo object that reflects the public method that has the specified name and is defined in the type represented by the current instance.

Parameters

name
A String containing the name of the public method to be returned.

Return Value

A MethodInfo object reflecting the public method that is defined in the type represented by the current instance and has the specified name, if found; otherwise, null .

Exceptions

Exception TypeCondition
AmbiguousMatchExceptionMore than one method matching the specified criteria was found.
ArgumentNullExceptionname is null .

Description

The search for name is case-sensitive.

This version of System.Type.GetMethod(System.String,System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[]) is equivalent to System.Type.GetMethod(System.String,System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[])(name, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance, null , null , null ).

If the current instance represents a generic type, this method returns the MethodInfo with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the methods of the class constraint, or the methods of Object if there is no class constraint; the methods of all interface constraints; and the methods of any interfaces inherited from class or interface constraints.

[Note: The name parameter cannot include type arguments.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetMethod(System.String, System.Type[]) Method

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

Summary

Returns a MethodInfo object that reflects the public method defined in the type represented by the current instance that has the specified name and parameter information.

Parameters

name
A String containing the name of the public method to be returned.
types
An array of Type objects. The elements in the array are of the same number, in the same order, and represent the same types as the parameters for the method to be returned.

Return Value

A MethodInfo object reflecting the public method defined in the type represented by the current instance that matches the specified criteria. If no public method matching the specified criteria is found, returns null .

Exceptions

Exception TypeCondition
AmbiguousMatchExceptionMore than one method matching the specified criteria was found.
ArgumentNullExceptionname or types is null .

-or-

At least one of the elements in types is null .

ArgumentExceptiontypes has more than one dimension.

Description

The search for name is case-sensitive.

This version of System.Type.GetMethod(System.String,System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[]) is equivalent to System.Type.GetMethod(System.String,System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[])(name, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance, null , types, null ).

If the current instance represents a generic type, this method returns the MethodInfo with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the methods of the class constraint, or the methods of Object if there is no class constraint; the methods of all interface constraints; and the methods of any interfaces inherited from class or interface constraints.

[Note: The name parameter cannot include type arguments.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetMethod(System.String, System.Type[], System.Reflection.ParameterModifier[]) Method

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

Summary

Returns a MethodInfo object that reflects the public method that has the specified name and is defined in the type represented by the current instance.

Parameters

name
A String containing the name of the public method to be returned.
types
An array of Type objects. The elements in the array are of the same number, in the same order, and represent the same types as the parameters for the method to be returned.

modifiers
The only defined value for this parameter is null .

Return Value

A MethodInfo object reflecting the public method that is defined in the type represented by the current instance and matches the specified criteria, if found; otherwise, null .

Exceptions

Exception TypeCondition
AmbiguousMatchExceptionMore than one method matching the specified criteria was found.
ArgumentNullExceptionname or types is null .

-or-

At least one of the elements in types is null .

ArgumentExceptiontypes has more than one dimension.

Description

The default binder does not process modifier .

The search for name is case-sensitive.

This version of System.Type.GetMethod(System.String,System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[]) is equivalent to System.Type.GetMethod(System.String,System.Reflection.BindingFlags,System.Reflection.Binder,System.Reflection.CallingConventions,System.Type[],System.Reflection.ParameterModifier[]) ( name, System.Reflection.BindingFlags.Public |System.Reflection.BindingFlags.Static |System.Reflection.BindingFlags.Instance , null , types , modifiers).

If the current instance represents a generic type, this method returns the MethodInfo with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the methods of the class constraint, or the methods of Object if there is no class constraint; the methods of all interface constraints; and the methods of any interfaces inherited from class or interface constraints.

[Note: The name parameter cannot include type arguments.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetMethods(System.Reflection.BindingFlags) Method

public abstract MethodInfo[] GetMethods(BindingFlags bindingAttr);

Summary

Returns an array of MethodInfo objects that reflect the methods defined in the type represented by the current instance that match the specified binding constraints.

Parameters

bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null .

Return Value

An array of MethodInfo objects reflecting the methods defined in the type represented by the current instance that match the constraints of bindingAttr . If no such methods found, returns an empty array. If the type represented by the current instance is from a loaded assembly and the caller does not have permission to reflect on non-public objects in loaded assemblies, returns only public methods.

Description

The following BindingFlags are used to define which members to include in the search:

The following BindingFlags values can be used to change how the search works:

[Note: For more information, see BindingFlags.]

If the current instance represents a generic type, this method returns the MethodInfo objects with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the methods of the class constraint, or the methods of Object if there is no class constraint; the methods of all interface constraints; and the methods of any interfaces inherited from class or interface constraints.

[Behaviors: As described above.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetMethods() Method

public MethodInfo[] GetMethods();

Summary

Returns the public methods defined in the type represented by the current instance.

Return Value

An array of MethodInfo objects reflecting the public methods defined in the type represented by the current instance. If no methods are found, returns an empty array.

Description

This version of System.Type.GetMethods is equivalent to System.Type.GetMethods( System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public ).

If the current instance represents a generic type, this method returns the MethodInfo objects with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the methods of the class constraint, or the methods of Object if there is no class constraint; the methods of all interface constraints; and the methods of any interfaces inherited from class or interface constraints.

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetNestedType(System.String) Method

public Type GetNestedType(string name);

Summary

Returns the public nested type defined in the type represented by the current instance

Parameters

name
A String containing the name of the public nested type to return. Specify the unqualified name of the nested type. [Note: For example, for a type B nested within A, if typeA represents the type object for A, the correct invocation is typeA.GetNestedType("B"). ]

Return Value

A Type object representing the public nested type with the specified name, if found; otherwise, null .

Exceptions

Exception TypeCondition
ArgumentNullExceptionname is null .

Description

The search for name is case-sensitive.

Use the simple name of the nested class for name; do not qualify it with the name of the outer class. CLS rules require a naming pattern for nested types; see Partition I.

If the current instance represents an unassigned type parameter of a generic type or method definition, this method does not search the nested types of the class constraint.

[Note: The name parameter cannot include type arguments. For example, passing "MyGenericNestedType<int>" to this method searches for a nested type with the text name "MyGenericNestedType<int>", rather than for a nested type named MyGenericNestedType that has one generic argument of type int .]

[Note: If the nested type is generic, what is returned is always a generic type definition.]

For information on constructing nested generic types from their generic type definitions, see the System.Type.MakeGenericType(System.Type[]) method.

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetNestedType(System.String, System.Reflection.BindingFlags) Method

public abstract Type GetNestedType(string name, BindingFlags bindingAttr);

Summary

Returns a nested types defined in the type represented by the current instance that match the specified binding constraints.

Parameters

name
A String containing the name of the nested type to return. Specify the unqualified name of the nested type. [Note: For example, for a type B nested within A, if typeA represents the type object for A, the correct invocation is typeA.GetNestedType("B").]

bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null .

Return Value

A Type object representing the nested type that matches the specified criteria, if found; otherwise, null . If the selected nested type is non-public, the current instance represents a type contained in a loaded assembly and the caller does not have sufficient permissions, returns null .

Exceptions

Exception TypeCondition
ArgumentNullExceptionname is null .

Description

The following BindingFlags are used to define which members to include in the search:

The following BindingFlags values can be used to change how the search works:

[Note: For more information, see BindingFlags.]

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the nested types of the class constraint.

[Note: The name parameter cannot include type arguments.]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetNestedTypes() Method

public Type[] GetNestedTypes();

Summary

Returns all the public types nested within the current Type.

Return Value

An array of Type objects representing all public types nested within the type represented by the current instance, if any. Otherwise, returns an empty Type array.

Description

This version of System.Type.GetNestedTypes is equivalent to System.Type.GetNestedTypes(System.Reflection.BindingFlags.Public).

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the nested types of the class constraint.

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetNestedTypes(System.Reflection.BindingFlags) Method

public abstract Type[] GetNestedTypes(BindingFlags bindingAttr);

Summary

Returns an array containing the nested types defined in the type represented by the current instance that match the specified binding constraints.

Parameters

bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null .

Return Value

An array of Type objects representing all types nested within the type represented by the current instance that match the specified binding constraints, if any. Otherwise, returns an empty Type array. If the type reflected by the current instance is contained in a loaded assembly, the type that matches the specified criteria is not public, and the caller does not have sufficient permission, returns only public types.

Description

The following BindingFlags are used to define which members to include in the search:

The following BindingFlags values can be used to change how the search works:

[Note: For more information, see BindingFlags.]

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the nested types of the class constraint.

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetProperties(System.Reflection.BindingFlags) Method

public abstract PropertyInfo[] GetProperties(BindingFlags bindingAttr);

Summary

Returns an array of PropertyInfo objects that reflect the properties defined for the type represented by the current instance that match the specified binding constraints.

Parameters

bindingAttr
A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null .

Return Value

An array of PropertyInfo objects that reflect the properties defined in the type represented by the current instance and match the constraints of bindingAttr . If no matching properties are found, returns an empty array. If the type represented by the current instance is from a loaded assembly and the caller does not have permission to reflect on non-public objects in loaded assemblies, returns only public properties.

Description

The following BindingFlags are used to define which members to include in the search:

The following BindingFlags values can be used to change how the search works:

[Note: For more information, see BindingFlags.]

If the current instance represents a generic type, this method returns the PropertyInfo objects with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the properties of the class constraint; the properties of all interface constraints; and the properties of any interfaces inherited from class or interface constraints.

[Behaviors: A property is considered by reflection to be public if it has at least one accessor that is public . Otherwise, the property is not public .]

Library

Reflection

See Also

System.Type Class, System Namespace

Type.GetProperties() Method

public PropertyInfo[] GetProperties();

Summary

Returns an array of PropertyInfo objects that reflect the public properties defined in the type represented by the current instance.

Return Value

An array of PropertyInfo objects that reflect the public properties defined in the type represented by the current instance. If no public properties are found, returns an empty