Mono Class Library: System Namespace

System.Type Class

Provides information about a type. [Edit]

See Also: Type Members

System.Object
     System.Reflection.MemberInfo
          System.Type

[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComDefaultInterface(typeof(System.Runtime.InteropServices._Type))]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Type : System.Reflection.MemberInfo, System.Reflection.IReflect, System.Runtime.InteropServices._Type

Thread Safety

This type is safe for multithreaded operations.

Remarks

The Type class is abstract, as is the System.Reflection.MemberInfo class and its subclasses System.Reflection.FieldInfo, System.Reflection.PropertyInfo, System.Reflection.MethodBase, and System.Reflection.EventInfo. System.Reflection.ConstructorInfo and System.Reflection.MethodInfo are subclasses of System.Reflection.MethodBase. The runtime provides non-public implementations of these classes.

Note: For example, Type.GetMethod(string, System.Reflection.BindingFlags, System.Reflection.Binder, System.Reflection.CallingConventions, Type[], System.Reflection.ParameterModifier[]) is typed as returning a System.Reflection.MethodInfo object. The returned object is actually an instance of the non-public runtime type that implements System.Reflection.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:

  • 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

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

Member TypeStaticNon-Static
ConstructorNoNo
FieldNoYes. A field is always hide-by-name-and-signature.
EventNot applicable The common type system rule is that the inheritance of an event is the same as that of the accessors that implement the event. Reflection treats events as hide-by-name-and-signature.
MethodNoYes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
Nested TypeNoNo
PropertyNot applicable The common type system rule is that the inheritance is the same as that of the accessors that implement the property. Reflection treats properties as hide-by-name-and-signature.

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 Type.IsGenericType contains definitions for some important terms.

[Edit]

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0