DynamicMethod.DeclaringType 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得宣告該方法的型別,而該方法總是 null 用於動態方法。
public:
virtual property Type ^ DeclaringType { Type ^ get(); };
public override Type DeclaringType { get; }
member this.DeclaringType : Type
Public Overrides ReadOnly Property DeclaringType As Type
屬性值
一律為 null。
範例
以下程式碼範例展示了動態方法的宣告類型。 此程式碼範例是本類別更大範例 DynamicMethod 的一部分。
// Display the declaring type, which is always null for dynamic
// methods.
if (hello.DeclaringType == null)
{
Console.WriteLine("\r\nDeclaringType is always null for dynamic methods.");
}
else
{
Console.WriteLine("DeclaringType: {0}", hello.DeclaringType);
}
' Display the declaring type, which is always Nothing for dynamic
' methods.
If hello.DeclaringType Is Nothing Then
Console.WriteLine(vbCrLf & "DeclaringType is always Nothing for dynamic methods.")
Else
Console.WriteLine("DeclaringType: {0}", hello.DeclaringType)
End If
備註
此特性對於動態方法總是回傳 null 。 即使動態方法在邏輯上與型別相關聯,也不會以型別來宣告。