ModuleBuilder.GetType 方法

定义

获取模块中定义的命名类型。

重载

名称 说明
GetType(String)

获取模块中定义的命名类型。

GetType(String, Boolean)

获取模块中定义的命名类型,可以选择忽略类型名称大小写。

GetType(String, Boolean, Boolean)

获取模块中定义的命名类型,可以选择忽略类型名称大小写。 (可选)如果未找到类型,则引发异常。

GetType(String)

Source:
ModuleBuilder.cs

获取模块中定义的命名类型。

public:
 override Type ^ GetType(System::String ^ className);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead.")]
public override Type? GetType(string className);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
public override Type? GetType(string className);
public override Type? GetType(string className);
public override Type GetType(string className);
[System.Runtime.InteropServices.ComVisible(true)]
public override Type GetType(string className);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead.")>]
override this.GetType : string -> Type
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")>]
override this.GetType : string -> Type
override this.GetType : string -> Type
[<System.Runtime.InteropServices.ComVisible(true)>]
override this.GetType : string -> Type
Public Overrides Function GetType (className As String) As Type

参数

className
String

要获取的名称 Type

返回

请求的类型(如果该类型在此模块中定义);否则,为 null.

属性

例外

长度为 className 零或大于 1023。

classNamenull

请求 Type 的不是公共对象,调用方不必 ReflectionPermission 反映当前程序集外部的非公共对象。

调用类初始值设定项并引发异常。

加载时 Type遇到错误。

注解

请勿使用此方法生成数组类型、指针类型或 byref 类型。 请改用TypeBuilder.MakeArrayTypeTypeBuilder.MakePointerTypeTypeBuilder.MakeByRefType方法。

适用于

GetType(String, Boolean)

Source:
ModuleBuilder.cs

获取模块中定义的命名类型,可以选择忽略类型名称大小写。

public:
 override Type ^ GetType(System::String ^ className, bool ignoreCase);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead.")]
public override Type? GetType(string className, bool ignoreCase);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
public override Type? GetType(string className, bool ignoreCase);
public override Type? GetType(string className, bool ignoreCase);
public override Type GetType(string className, bool ignoreCase);
[System.Runtime.InteropServices.ComVisible(true)]
public override Type GetType(string className, bool ignoreCase);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead.")>]
override this.GetType : string * bool -> Type
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")>]
override this.GetType : string * bool -> Type
override this.GetType : string * bool -> Type
[<System.Runtime.InteropServices.ComVisible(true)>]
override this.GetType : string * bool -> Type
Public Overrides Function GetType (className As String, ignoreCase As Boolean) As Type

参数

className
String

要获取的名称 Type

ignoreCase
Boolean

如果 true,则搜索不区分大小写。 如果 false,搜索区分大小写。

返回

请求的类型(如果该类型在此模块中定义);否则,为 null.

属性

例外

长度为 className 零或大于 1023。

classNamenull

请求 Type 的不是公共对象,调用方不必 ReflectionPermission 反映当前程序集外部的非公共对象。

调用类初始值设定项并引发异常。

注解

请勿使用此方法生成数组类型、指针类型或 byref 类型。 请改用TypeBuilder.MakeArrayTypeTypeBuilder.MakePointerTypeTypeBuilder.MakeByRefType方法。

适用于

GetType(String, Boolean, Boolean)

Source:
ModuleBuilder.cs

获取模块中定义的命名类型,可以选择忽略类型名称大小写。 (可选)如果未找到类型,则引发异常。

public:
 override Type ^ GetType(System::String ^ className, bool throwOnError, bool ignoreCase);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead.")]
public override Type? GetType(string className, bool throwOnError, bool ignoreCase);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
public override Type? GetType(string className, bool throwOnError, bool ignoreCase);
public override Type? GetType(string className, bool throwOnError, bool ignoreCase);
public override Type GetType(string className, bool throwOnError, bool ignoreCase);
[System.Runtime.InteropServices.ComVisible(true)]
public override Type GetType(string className, bool throwOnError, bool ignoreCase);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead.")>]
override this.GetType : string * bool * bool -> Type
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")>]
override this.GetType : string * bool * bool -> Type
override this.GetType : string * bool * bool -> Type
[<System.Runtime.InteropServices.ComVisible(true)>]
override this.GetType : string * bool * bool -> Type
Public Overrides Function GetType (className As String, throwOnError As Boolean, ignoreCase As Boolean) As Type

参数

className
String

要获取的名称 Type

throwOnError
Boolean

true 如果找不到类型,则引发异常; falsenull返回 。

ignoreCase
Boolean

如果 true,则搜索不区分大小写。 如果 false,搜索区分大小写。

返回

指定类型(如果该类型在此模块中声明);否则,为 null.

属性

例外

长度为 className 零或大于 1023。

classNamenull

请求 Type 的不是公共对象,调用方不必 ReflectionPermission 反映当前程序集外部的非公共对象。

调用类初始值设定项并引发异常。

throwOnErrortrue 且找不到指定的类型。

注解

throwOnError 参数仅影响找不到类型时发生的情况。 它不会影响可能引发的任何其他异常。 具体而言,如果找到类型但无法加载,即使为 <a0/>,也可以引发

请勿使用此方法生成数组类型、指针类型或 byref 类型。 请改用TypeBuilder.MakeArrayTypeTypeBuilder.MakePointerTypeTypeBuilder.MakeByRefType方法。

适用于