public abstract class Type : Object
Object
MemberInfo (excluded)
Type
mscorlib
BCL
Provides information about a type.
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[]).
- Classes
- Value types
- Arrays
- Interfaces
- Pointers
- Enumerations
- Constructed generic types and generic type definitions
- Type arguments and type parameters of constructed generic types, generic type definitions, and generic method definitions
Member Type Static Constructor No Field No Event Not applicable Method No Nested Type No Property Not 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.
System Namespace
Type Constructors
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
protected Type();
Constructs a new instance of the Type class.
Reflection
System.Type Class, System Namespace
public bool Equals(Type o);
Determines if the underlying system type of the current Type is the same as the underlying system type of the specified Type.
- o
- The Type whose underlying system type is to be compared with the underlying system type of the current Type.
trueif the underlying system type of o is the same as the underlying system type of the current Type; otherwise,false.
Reflection
System.Type Class, System Namespace
public virtual int GetArrayRank();
Returns the number of dimensions in the current Type.
A Int32 containing the number of dimensions in the current Type.
Exception Type Condition ArgumentException The current Type is not an array.
System.Type Class, System Namespace
protected abstract TypeAttributes GetAttributeFlagsImpl();
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.
A TypeAttributes value that signifies the attributes of the type represented by the current instance.
[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.]
Reflection
System.Type Class, System Namespace
public ConstructorInfo GetConstructor(BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers);
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.
- 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
nullto 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.
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, returnsnull. 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, returnsnull.
Exception Type Condition ArgumentNullException types is null, or at least one of the elements in types isnull.
ArgumentException types has more than one dimension.
The following BindingFlags are used to define which constructors to include in the search:
[Note: For more information, see BindingFlags.]
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public constructors in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public constructors (that is, private and protected constructors) in the search.
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.
Reflection
System.Type Class, System Namespace
public ConstructorInfo GetConstructor(Type[] types);
Returns a public instance constructor defined in the type represented by the current instance. The parameters of the constructor match the specified argument types.
- 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.
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, returnsnull.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.
Exception Type Condition ArgumentNullException types is null, or at least one of the elements in types isnull.
ArgumentException types has more than one dimension.
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).
Reflection
System.Type Class, System Namespace
public ConstructorInfo[] GetConstructors();
Returns an array of the public constructors defined in the type represented by the current instance.
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.
This version of System.Type.GetConstructors is equivalent to System.Type.GetConstructors(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).
Reflection
System.Type Class, System Namespace
public abstract ConstructorInfo[] GetConstructors(BindingFlags bindingAttr);
Returns an array of constructors defined in the type represented by the current instance, under the specified binding constraints.
- bindingAttr
- A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns
null.
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, returnsnull.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.
The following BindingFlags are used to define which constructors to include in the search:
[Note: For more information, see BindingFlags.]
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public constructors in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public constructors (that is, private and protected constructors) in the search.
[Behaviors: As described above.]
Reflection
System.Type Class, System Namespace
public virtual MemberInfo[] GetDefaultMembers();
Returns an array of MemberInfo objects that reflect the default members defined in the type represented by the current instance.
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.
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.]
Reflection
System.Type Class, System Namespace
public abstract Type GetElementType();
Returns the element type of the current Type .
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, returnsnullif 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.
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.Int32TestType element type is null
System.Type Class, System Namespace
public EventInfo GetEvent(string name);
Returns a EventInfo object reflecting the public event that has the specified name and is defined in the type represented by the current instance.
- name
- A String containing the name of the public event to be returned.
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.
Exception Type Condition ArgumentNullException name is null.
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.
Reflection
System.Type Class, System Namespace
public abstract EventInfo GetEvent(string name, BindingFlags bindingAttr);
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.
- 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.
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, returnsnull. If the event is not public, the current instance represents a type from a loaded assembly, and the caller does not have sufficient permission, returnsnull.If the current instance represents a generic type, this method returns the EventInfo with the type parameters replaced by the appropriate type arguments.
Exception Type Condition ArgumentNullException name is null.
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:
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public events in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public events(that is, private and protected events) in the search.
[Note: For more information, see BindingFlags.]
- System.Reflection.BindingFlags.DeclaredOnly to search only the events declared on the type, not events that were simply inherited.
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.]
Reflection
System.Type Class, System Namespace
public virtual EventInfo[] GetEvents();
Returns an array of EventInfo objects that reflect the public events defined in the type represented by the current instance.
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.
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).]
Reflection
System.Type Class, System Namespace
public abstract EventInfo[] GetEvents(BindingFlags bindingAttr);
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.
- bindingAttr
- A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns null.
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.
The following BindingFlags are used to define which events to include in the search:
[Note: For more information, see BindingFlags.]
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public events in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public events (that is, private and protected events) in the search.
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.]
Reflection
System.Type Class, System Namespace
public abstract FieldInfo GetField(string name, BindingFlags bindingAttr);
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.
- 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.
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, returnsnull. If the field is not public, the current type is from a loaded assembly, and the caller does not have sufficient permission, returnsnull.If the current instance represents a generic type, this method returns the FieldInfo with the type parameters replaced by the appropriate type arguments.
Exception Type Condition ArgumentNullException name is null.
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:
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public fields in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public fields (that is, private and protected fields) in the search.
[Note: For more information, see BindingFlags.]
- System.Reflection.BindingFlags.DeclaredOnly to search only the fields declared in the type, not fields that were simply inherited.
- System.Reflection.BindingFlags.IgnoreCase to ignore the case of name.
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.]
Reflection
System.Type Class, System Namespace
public FieldInfo GetField(string name);
Returns a FieldInfo object reflecting the field that has the specified name and is defined in the type represented by the current instance.
- name
- A String containing the name of the field to be returned.
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, returnsnull.If the current instance represents a generic type, this method returns the FieldInfo with the type parameters replaced by the appropriate type arguments.
Exception Type Condition ArgumentNullException name is null.
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.
Reflection
System.Type Class, System Namespace
public FieldInfo[] GetFields();
Returns an array of FieldInfo objects that reflect the public fields defined in the type represented by the current instance.
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.
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.
Reflection
System.Type Class, System Namespace
public abstract FieldInfo[] GetFields(BindingFlags bindingAttr);
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.
- bindingAttr
- A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns
null.
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.
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:
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static in order to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public fields in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public fields (that is, private and protected fields) in the search.
[Note: For more information, see BindingFlags.]
- System.Reflection.BindingFlags.DeclaredOnly to search only the fields declared in the type, not fields that were simply inherited.
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.]
Reflection
System.Type Class, System Namespace
public virtual Type[] GetGenericArguments()
Returns an array of Type objects that represent the type arguments of a generic type or the type parameters of a generic type definition.
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.
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.
For an example of using this method, see the example for System.Type.GenericParameterPosition.
Reflection
System.Type Class, System Namespace
public virtual Type[] GetGenericParameterConstraints()
Returns an array of Type objects that represent the type constraints on the current generic type parameter.
An array of Type objects that represent the type constraints on the current generic type parameter.
Exception Type Condition InvalidOperationException The current Type object is not a generic type parameter. That is, the System.Type.IsGenericParameter property returns false.
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.
Reflection
System.Type Class, System Namespace
public virtual Type GetGenericTypeDefinition()
Returns a Type object that represents a generic type from which the current type can be constructed.
A Type object representing a generic type from which the current type can be constructed.
Exception Type Condition InvalidOperationException The current type is not a generic type. That is, System.Type.HasGenericArguments returns false.
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.
For an example of using this method, see the example for System.Type.MakeGenericType.
Reflection
System.Type Class, System Namespace
public override int GetHashCode();
Generates a hash code for the current instance.
A Int32 containing the hash code for this instance.
The algorithm used to generate the hash code is unspecified.[Note: This method overrides System.Object.GetHashCode .]
System.Type Class, System Namespace
public abstract Type GetInterface(string name, bool ignoreCase);
Returns the specified interface, specifying whether to do a case-sensitive search.
- name
- A String containing the name of the interface to return.
- ignoreCase
- A Boolean where
trueindicates that the name search is to be done case-insensitively, andfalseperforms a case-sensitive search.
A Type object representing the interface with the specified name, implemented or inherited by the type represented by the instance, if found; otherwise,null.
Exception Type Condition ArgumentNullException name is null.AmbiguousMatchException The current instance represents a type that implements the same generic interface with different type arguments.
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.]
Reflection
System.Type Class, System Namespace
public Type GetInterface(string name);
Searches for the interface with the specified name.
- name
- A String containing the name of the interface to get.
A Type object representing the interface with the specified name, implemented or inherited by the current Type, if found; otherwise,null.
Exception Type Condition ArgumentNullException name is null.AmbiguousMatchException The current instance represents a type that implements the same generic interface with different type arguments.
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.]
Reflection
System.Type Class, System Namespace
public abstract Type[] GetInterfaces();
Returns all interfaces implemented or inherited by the type represented by the current instance.
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.
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.]
Reflection
System.Type Class, System Namespace
public virtual MemberInfo[] GetMember(string name, BindingFlags bindingAttr);
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.
- 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.
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, returnsnull.
Exception Type Condition ArgumentNullException name is null.
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:
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public members in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public members (that is, private and protected members) in the search.
[Note: For more information, see BindingFlags.]
- System.Reflection.BindingFlags.DeclaredOnly to search only the members declared in the type, not members that were simply inherited.
- System.Reflection.BindingFlags.IgnoreCase to ignore the case of name.
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.]
Reflection
System.Type Class, System Namespace
public MemberInfo[] GetMember(string name);
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.
- name
- A String containing the name of the members to be returned.
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.
Exception Type Condition ArgumentNullException name is null.
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.]
Reflection
System.Type Class, System Namespace
public abstract MemberInfo[] GetMembers(BindingFlags bindingAttr);
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.
- bindingAttr
- A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns
null.
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.
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:
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public members in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public members (that is, private and protected members) in the search.
[Note: For more information, see BindingFlags.]
- System.Reflection.BindingFlags.DeclaredOnly to search only the members declared in the type, not members that were simply inherited.
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.]
Reflection
System.Type Class, System Namespace
public MemberInfo[] GetMembers();
Returns an array of MemberInfo objects that reflect the public members defined in the type represented by the current instance.
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.
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.
Reflection
System.Type Class, System Namespace
public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers);
Returns a MethodInfo object that reflects the method that matches the specified criteria and is defined in the type represented by the current instance.
- 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
nullto 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.
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, returnsnull. 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, returnsnull.
Exception Type Condition AmbiguousMatchException More than one method matching the specified criteria was found. ArgumentNullException name or types is null.-or-
At least one of the elements in types is
null.
ArgumentException types has more than one dimension.
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:
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public members in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public members (that is, private and protected members) in the search.
[Note: For more information, see BindingFlags.]
- System.Reflection.BindingFlags.DeclaredOnly to search only the members declared in the type, not members that were simply inherited.
- System.Reflection.BindingFlags.IgnoreCase to ignore the case of name.
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.]
Reflection
System.Type Class, System Namespace
public MethodInfo GetMethod(string name, BindingFlags bindingAttr);
Returns a MethodInfo object that reflects the method that has the specified name and is defined in the type represented by the current instance.
- 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.
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.
Exception Type Condition AmbiguousMatchException More than one method matching the specified criteria was found. ArgumentNullException name is null.
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:
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public members in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public members (that is, private and protected members) in the search.
[Note: For more information, see BindingFlags.]
- System.Reflection.BindingFlags.DeclaredOnly to search only the members declared in the type, not members that were simply inherited.
- System.Reflection.BindingFlags.IgnoreCase to ignore the case of name.
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.]
Reflection
System.Type Class, System Namespace
public MethodInfo GetMethod(string name);
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.
- name
- A String containing the name of the public method to be returned.
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.
Exception Type Condition AmbiguousMatchException More than one method matching the specified criteria was found. ArgumentNullException name is null.
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.]
Reflection
System.Type Class, System Namespace
public MethodInfo GetMethod(string name, Type[] types);
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.
- 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.
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, returnsnull.
Exception Type Condition AmbiguousMatchException More than one method matching the specified criteria was found. ArgumentNullException name or types is null.-or-
At least one of the elements in types is
null.
ArgumentException types has more than one dimension.
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.]
Reflection
System.Type Class, System Namespace
public MethodInfo GetMethod(string name, Type[] types, ParameterModifier[] modifiers);
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.
- 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.
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.
Exception Type Condition AmbiguousMatchException More than one method matching the specified criteria was found. ArgumentNullException name or types is null.-or-
At least one of the elements in types is
null.
ArgumentException types has more than one dimension.
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.]
Reflection
System.Type Class, System Namespace
public abstract MethodInfo[] GetMethods(BindingFlags bindingAttr);
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.
- bindingAttr
- A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns
null.
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.
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:
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public members in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public members (that is, private and protected members) in the search.
[Note: For more information, see BindingFlags.]
- System.Reflection.BindingFlags.DeclaredOnly to search only the members declared in the type, not members that were simply inherited.
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.]
Reflection
System.Type Class, System Namespace
public MethodInfo[] GetMethods();
Returns the public methods defined in the type represented by the current instance.
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.
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.
Reflection
System.Type Class, System Namespace
public Type GetNestedType(string name);
Returns the public nested type defined in the type represented by the current instance
- 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"). ]
A Type object representing the public nested type with the specified name, if found; otherwise,null.
Exception Type Condition ArgumentNullException name is null.
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.
Reflection
System.Type Class, System Namespace
public abstract Type GetNestedType(string name, BindingFlags bindingAttr);
Returns a nested types defined in the type represented by the current instance that match the specified binding constraints.
- 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.
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, returnsnull.
Exception Type Condition ArgumentNullException name is null.
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:
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public members in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public members (that is, private and protected members) in the search.
[Note: For more information, see BindingFlags.]
- System.Reflection.BindingFlags.DeclaredOnly to search only the members declared in the type, not members that were simply inherited.
- System.Reflection.BindingFlags.IgnoreCase to ignore the case of name.
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.]
Reflection
System.Type Class, System Namespace
public Type[] GetNestedTypes();
Returns all the public types nested within the current Type.
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.
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.
Reflection
System.Type Class, System Namespace
public abstract Type[] GetNestedTypes(BindingFlags bindingAttr);
Returns an array containing the nested types defined in the type represented by the current instance that match the specified binding constraints.
- bindingAttr
- A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns
null.
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.
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:
- Specify System.Reflection.BindingFlags.Public to include public members in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public members (that is, private and protected members) in the search.
[Note: For more information, see BindingFlags.]
- System.Reflection.BindingFlags.DeclaredOnly to search only the members declared in the type, not members that were simply inherited.
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.
Reflection
System.Type Class, System Namespace
public abstract PropertyInfo[] GetProperties(BindingFlags bindingAttr);
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.
- bindingAttr
- A bitwise combination of BindingFlags values that control the binding process. If zero is specified, this method returns
null.
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.
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:
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than
null.- Specify System.Reflection.BindingFlags.Public to include public members in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public members (that is, private and protected members) in the search.
[Note: For more information, see BindingFlags.]
- System.Reflection.BindingFlags.DeclaredOnly to search only the members declared in the type, not members that were simply inherited.
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
publicif it has at least one accessor that ispublic. Otherwise, the property is notpublic.]
Reflection
System.Type Class, System Namespace
public PropertyInfo[] GetProperties();
Returns an array of PropertyInfo objects that reflect the public properties defined in the type represented by the current instance.
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