GetType Method (String, Boolean)
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Gets the Type object with the specified name in the assembly instance and optionally throws an exception if the type is not found.
Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Overridable Function GetType ( _
name As String, _
throwOnError As Boolean _
) As Type
public virtual Type GetType(
string name,
bool throwOnError
)
public:
virtual Type^ GetType(
String^ name,
bool throwOnError
)
abstract GetType :
name:string *
throwOnError:bool -> Type
override GetType :
name:string *
throwOnError:bool -> Type
public function GetType(
name : String,
throwOnError : boolean
) : Type
Parameters
- name
Type: System. . :: . .String
The full name of the type.
- throwOnError
Type: System. . :: . .Boolean
true to throw an exception if the type is not found; false to return nullNothingnullptrunita null reference (Nothing in Visual Basic).
Return Value
Type: System. . :: . .Type
An object that represents the specified class.
Remarks
This method only searches the current assembly instance. The name parameter includes the namespace but not the assembly. To search other assemblies for a type, use the Type..::..GetType(String) method overload, which can optionally include an assembly display name as part of the type name.
The throwOnError parameter only affects what happens when the type is not found. It does not affect any other exceptions that might be thrown. In particular, if the type is found but cannot be loaded, TypeLoadException can be thrown even if throwOnError is false.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.