Click or drag to resize
TypeGetType Method (String, Boolean, Boolean)
Gets the Type with the specified name, specifying whether to perform a case-sensitive search and whether to throw an exception if the type is not found.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static Type GetType(
	string typeName,
	bool throwOnError,
	bool ignoreCase
)

Parameters

typeName
Type: SystemString
The assembly-qualified name of the type to get. See AssemblyQualifiedName. If the type is in the currently executing assembly or in Mscorlib.dll, it is sufficient to supply the type name qualified by its namespace.
throwOnError
Type: SystemBoolean
true to throw an exception if the type cannot be found; false to return null.Specifying false also suppresses some other exception conditions, but not all of them. See the Exceptions section.
ignoreCase
Type: SystemBoolean
true to perform a case-insensitive search for typeName, false to perform a case-sensitive search for typeName.

Return Value

Type: Type
The type with the specified name. If the type is not found, the throwOnError parameter specifies whether null is returned or an exception is thrown. In some cases, an exception is thrown regardless of the value of throwOnError. See the Exceptions section.
Exceptions
ExceptionCondition
ArgumentNullExceptiontypeName is null.
TargetInvocationExceptionA class initializer is invoked and throws an exception.
TypeLoadExceptionthrowOnError is true and the type is not found. -or-throwOnError is true and typeName contains invalid characters, such as an embedded tab.-or-throwOnError is true and typeName is an empty string.-or-throwOnError is true and typeName represents an array type with an invalid size. -or-typeName represents an array of TypedReference.
ArgumentExceptionthrowOnError is true and typeName contains invalid syntax. For example, "MyType[,*,]".-or- typeName represents a generic type that has a pointer type, a ByRef type, or Void as one of its type arguments.-or-typeName represents a generic type that has an incorrect number of type arguments.-or-typeName represents a generic type, and one of its type arguments does not satisfy the constraints for the corresponding type parameter.
FileNotFoundExceptionthrowOnError is true and the assembly or one of its dependencies was not found.
FileLoadExceptionThe assembly or one of its dependencies was found, but could not be loaded.
BadImageFormatExceptionThe assembly or one of its dependencies is not valid. -or-Version 2.0 or later of the common language runtime is currently loaded, and the assembly was compiled with a later version.
See Also