Represents type declarations: class types, interface types, array types, value types, and enumeration types.
For a list of all members of this type, see Type Members.
[Visual Basic] <Serializable> <ClassInterface(ClassInterfaceType.AutoDual)> MustInherit Public Class Type Inherits MemberInfo Implements IReflect [C#] [Serializable] [ClassInterface(ClassInterfaceType.AutoDual)] public abstract class Type : MemberInfo, IReflect [C++] [Serializable] [ClassInterface(ClassInterfaceType::AutoDual)] public __gc __abstract class Type : public MemberInfo, IReflect [JScript] public Serializable ClassInterface(ClassInterfaceType.AutoDual) abstract class Type extends MemberInfo implements IReflect
This type is safe for multithreaded operations.
Type is the root of the System.Reflection functionality and is the primary way to access metadata. Use the members of Type to get information about a type declaration, such as the constructors, methods, fields, properties, and events of a class, as well as the module and the assembly in which the class is deployed.
Without ReflectionPermission, code can access only the public members of loaded assemblies. This includes, but is not limited to, unrestricted access to Object.GetType, access to public exported types through Type.GetType, and access to GetTypeFromHandle. Some properties of Type, such as FullName and Attributes, are accessible without ReflectionPermission.
Type is an abstract base class that allows multiple implementations. The system will always provide the derived class RuntimeType. In reflection, all classes beginning with the word Runtime are created only once per object in the system and support comparison operations.
Notes to Inheritors: When you inherit from Type, you must override the following members: GUID, InvokeMember(String, BindingFlags, Binder, Object, Object, ParameterModifier, CultureInfo, String), Module, Assembly, TypeHandle, FullName, Namespace, AssemblyQualifiedName, BaseType, GetConstructorImpl, GetConstructors(BindingFlags), GetMethodImpl, GetMethods(BindingFlags), GetField(String, BindingFlags), GetFields(BindingFlags), GetInterface(String, Boolean), GetInterfaces, GetEvent(String, BindingFlags), GetEvents(BindingFlags), GetPropertyImpl, GetProperties(BindingFlags), GetNestedType(String, BindingFlags), GetNestedTypes(BindingFlags), GetAttributeFlagsImpl, IsArrayImpl, IsByRefImpl, IsPointerImpl, IsPrimitiveImpl, IsCOMObjectImpl, GetElementType, HasElementTypeImpl, UnderlyingSystemType, MemberInfo.Name, MemberInfo.IsDefined, System.Reflection.MemberInfo.GetCustomAttributes(Boolean), and System.Reflection.MemberInfo.GetCustomAttributes(Type, Boolean).
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 In multithreading scenarios, do not lock Type objects in order to synchronize access to static (Shared in Visual Basic) data. Other code, over which you have no control, might also lock your class type. This might result in a deadlock. Intead, synchronize access to static data by locking a private static (Shared in Visual Basic) object.
This class is thread safe; multiple threads can concurrently read from or write to an instance of this type. An instance of Type can represent any of the following types:
- Value types
A reference to the Type object associated with a type can be obtained in the following ways.
- The Object.GetType method returns a Type object that represents the type of an instance.
- The static GetType methods return a Type object that represents a type specified by its fully qualified name.
- The Module.GetTypes, Module.GetType, and Module.FindTypes methods return Type objects that represent the types defined in a module. The first can be used to obtain an array of Type objects for all of the public and private types defined in a module. (You can obtain an instance of Module through the Assembly.GetModule or Assembly.GetModules methods, or through the Type.Module property.)
- The FindInterfaces method returns a filtered list of interface types supported by a type.
- The GetElementType method returns a Type object that represents the element.
- The GetInterfaces and GetInterface methods return Type objects representing the interface types supported by a type.
- The GetTypeArray method returns an array of Type objects representing the types specified by an arbitrary set of objects. The objects are specified with an array of type Object.
- The GetTypeFromProgID and GetTypeFromCLSID methods are provided for COM interoperability. They return a Type object that represents the type specified by a ProgID or CLSID.
- The GetTypeFromHandle method is provided for interoperability. It returns a Type object that represents the type specified by a class handle.
- The C# or C++ typeof operator obtains the Type object for a type.
- The Visual Basic .NET GetType operator obtains the Type object for a type.
Note A derived class can access protected members of the calling code's base classes. Also, access is allowed to assembly members of the calling code's assembly. As a rule, if you are allowed access in early bound code, then you are also allowed access in late bound code.
Note Interfaces that extend other interfaces do not inherit the methods defined in the extended interfaces.
.NET Compact Framework Platform Note: Version 1.0 of the .NET Compact Framework does not support the TypeHandle property.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
Assembly: Mscorlib (in Mscorlib.dll)