ModuleBuilder.GetType 方法

定義

取得模組中定義的命名型別。

多載

名稱 Description
GetType(String)

取得模組中定義的命名型別。

GetType(String, Boolean)

取得模組中定義的命名型別,可選擇性地忽略型別名稱的情況。

GetType(String, Boolean, Boolean)

取得模組中定義的命名型別,可選擇性地忽略型別名稱的情況。 若找不到該型別,則可選擇拋出例外。

GetType(String)

取得模組中定義的命名型別。

public:
 override Type ^ GetType(System::String ^ className);
public override Type GetType(string className);
[System.Runtime.InteropServices.ComVisible(true)]
public override Type GetType(string className);
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 長度為零或大於10²³。

classNamenull

請求 Type 的對象為非公開物件,呼叫者無需 ReflectionPermission 反映當前集會外的非公開物件。

會呼叫一個類別初始化器並拋出例外。

載入 時 Type會遇到錯誤。

備註

請勿使用此方法產生陣列類型、指標類型或 byref 類型。 改用 TypeBuilder.MakeArrayTypeTypeBuilder.MakePointerTypeTypeBuilder.MakeByRefType 方法。

適用於

GetType(String, Boolean)

取得模組中定義的命名型別,可選擇性地忽略型別名稱的情況。

public:
 override Type ^ GetType(System::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);
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 長度為零或大於10²³。

classNamenull

請求 Type 的對象為非公開物件,呼叫者無需 ReflectionPermission 反映當前集會外的非公開物件。

會呼叫一個類別初始化器並拋出例外。

備註

請勿使用此方法產生陣列類型、指標類型或 byref 類型。 改用 TypeBuilder.MakeArrayTypeTypeBuilder.MakePointerTypeTypeBuilder.MakeByRefType 方法。

適用於

GetType(String, Boolean, Boolean)

取得模組中定義的命名型別,可選擇性地忽略型別名稱的情況。 若找不到該型別,則可選擇拋出例外。

public:
 override Type ^ GetType(System::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);
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 若找不到該型別,則拋出例外; false 返回 null

ignoreCase
Boolean

true,則搜尋不區分大小寫。 若 false,則搜尋為大小寫區分。

傳回

若該類型在此模組中宣告,則為指定型別;否則,。 null

屬性

例外狀況

className 長度為零或大於10²³。

classNamenull

請求 Type 的對象為非公開物件,呼叫者無需 ReflectionPermission 反映當前集會外的非公開物件。

會呼叫一個類別初始化器並拋出例外。

throwOnErrortrue ,且找不到指定的類型。

備註

參數 throwOnError 只影響當未找到該型別時會發生什麼。 這不會影響其他可能被拋出的例外情況。 特別地,若找到型別但無法載入,TypeLoadException即使 是 false,仍可拋出 throwOnError

請勿使用此方法產生陣列類型、指標類型或 byref 類型。 改用 TypeBuilder.MakeArrayTypeTypeBuilder.MakePointerTypeTypeBuilder.MakeByRefType 方法。

適用於