Returns the Type with the specified name, optionally performing a case-insensitive search and optionally throwing an exception if an error occurs while loading the Type.
- typeName
- A string containing the name of the Type to return.
- throwOnError
- A bool. Specify true to throw a TypeLoadException if an error occurs while loading the Type. Specify false to ignore errors while loading the Type.
- ignoreCase
- A bool. Specify true to perform a case-insensitive search for typeName. Specify false to perform a case-sensitive search for typeName .
The Type with the specified name, if found; otherwise, null. If the requested type is non-public and the caller does not have permission to reflect non-public objects outside the current assembly, this method returns null.
Type Reason System.Security.Permissions.ReflectionPermission Requires permission to retrieve information on non-public members of types in loaded assemblies. See System.Security.Permissions.ReflectionPermissionFlag.TypeInformation.
Type Reason ArgumentNullException typeName is null. System.Reflection.TargetInvocationException A type initializer was invoked and threw an exception. TypeLoadException throwOnError is true and an error was encountered while loading the selected Type.
typeName can be a simple type name, a fully qualified name, or a complex name that includes an assembly name.
Note: Type.AssemblyQualifiedName returns a fully qualified type name including nested types, the assembly name, and generic type arguments.If typeName includes only the name of the Type, this method searches in the calling object's assembly, then in the mscorlib.dll assembly. If typeName is fully qualified with the partial or complete assembly name, this method searches in the specified assembly.
Note:The following table shows calls to GetType for various types. (Some long strings have been wrapped to fit in the right column.)
To Get this Type Use this String An unmanaged pointer to MyType Type.GetType("MyType*") An unmanaged pointer to a pointer to MyType Type.GetType("MyType**") A managed pointer or reference to MyType Type.GetType("MyType&")Note that unlike pointers, references are limited to one level. A parent class and a nested class Type.GetType("MyParentClass+MyNestedClass") A one-dimensional array with a lower bound of 0 Type.GetType("MyArray[]") A one-dimensional array with an unknown lower bound Type.GetType("MyArray[*]") An n-dimensional array A comma (,) inside the brackets a total of n-1 times. For example, System.Object[,,] represents a three-dimensional Object array. A two-dimensional array's array Type.GetType("MyArray[][]") A rectangular two-dimensional array with unknown lower bounds Type.GetType("MyArray[*,*]") or Type.GetType("MyArray[,]") A generic type with one type argument Type.GetType("MyGenericType[MyType]") A generic type with two type arguments Type.GetType("MyGenericType[MyType,AnotherType]") A generic type with two assembly-qualified type arguments Type.GetType("MyGenericType[[MyType,MyAssembly], [AnotherType,AnotherAssembly]]") An assembly-qualified generic type with an assembly-qualified type argument Type.GetType("MyGenericType[[MyType,MyAssembly]] ,MyGenericTypeAssembly") A generic type whose type argument is a generic type with two type arguments Type.GetType("MyGenericType[AnotherGenericType [MyType,AnotherType]]")
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0