NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Type Class

Represents type declarations: class types, interface types, array types, value types, and enumeration types.

Object
   MemberInfo
      Type

[Visual Basic]
MustInherit Public Class Type
   Inherits MemberInfo
   Implements IReflect
[C#]
public abstract class Type : MemberInfo, IReflect
[C++]
public __gc __abstract class Type : public MemberInfo, IReflect
[JScript]
public abstract class Type extends MemberInfo, IReflect

Remarks

This class is abstract primarily because its functionality is required of the different services provided by the runtime.

This class is the primary means by which to access metadata, and it acts as a gateway to the Reflection API. It provides methods for obtaining 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.

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 the synchronization of multiple static method invocations and for comparison of Type objects through reference comparisons.

A reference to the Type object associated with a type can be obtained in several ways:

1. The GetType method provided by Object returns a Type object that represents the type of an instance.

2. The static GetType method provided by Type returns a Type object that represents a type specified by its fully qualified name.

3. The GetTypes, GetType, and FindTypes methods provided by Module 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. (An instance of Module is obtained through the static GetModule method provided by Module, or through the Module property provided by Type.)

4. The FindInterfaces method returns a filtered list of interface types supported by a class.

5. The GetElementType method returns a Type object that represents the element.

6. The GetInterfaces and GetInterface methods return Type objects representing the interface types supported by a class.

7. The GetTypeArray method returns an array of Type objects representing the types specified by an arbitrary set of objects. The objects are specified with a Variant array.

8. The GetTypeFromProgID methods are provided for interoperability. The first returns a Type object that represents the type specified by a class handle, and the latter returns a Type object that represents the type specified by a ProgID.

9. The GetTypeFromHandle and GetTypeFromProgID methods are provided for interoperability. The first returns a Type object that represents the type specified by a class handle and the latter returns a Type object that represents the type specified by a ProgID.

A Note on Security: Without ReflectionPermission, a subclass is only allowed to access the public members of a class. That is, invoking the GetMethods method on the Type object for a class will only return the public methods of that class. Furthermore, invoking GetMethod with the name of a non-public method will return null, as if it did not exist.

A Note on Reflection over Interfaces: Interfaces that extend other interfaces do not inherit the methods defined in the extended interfaces. For example, in the following code, I2 does not have a MethodA, even though all classes that implement I2 will have to create an I1. In effect, all classes that implement I2 also implement I1. See the Examples section below.

Requirements

Namespace: System

Assembly: mscorlib.dll

See Also

Type Members | System Namespace | Object | System.Reflection | ReflectionPermission