共用方式為


DynamicMethod.InitLocals 屬性

定義

取得或設定值,表示在此方法中的區域變數是否以零起始。

public:
 property bool InitLocals { bool get(); void set(bool value); };
public bool InitLocals { get; set; }
member this.InitLocals : bool with get, set
Public Property InitLocals As Boolean

屬性值

如果在此方法中的區域變數以零起始,則為 true;否則為 false。 預設為 true

範例

下列程式代碼範例會顯示 InitLocals 動態方法的 屬性。 此程式代碼範例是提供給 類別之較大範例的 DynamicMethod 一部分。

// Display the default value for InitLocals.
if (hello->InitLocals)
{
    Console::Write("\r\nThis method contains verifiable code.");
}
else
{
    Console::Write("\r\nThis method contains unverifiable code.");
}
Console::WriteLine(" (InitLocals = {0})", hello->InitLocals);
// Display the default value for InitLocals.
if (hello.InitLocals)
{
    Console.Write("\r\nThis method contains verifiable code.");
}
else
{
    Console.Write("\r\nThis method contains unverifiable code.");
}
Console.WriteLine(" (InitLocals = {0})", hello.InitLocals);
' Display the default value for InitLocals.
If hello.InitLocals Then
    Console.Write(vbCrLf & "This method contains verifiable code.")
Else
    Console.Write(vbCrLf & "This method contains unverifiable code.")
End If
Console.WriteLine(" (InitLocals = {0})", hello.InitLocals)

備註

如果此屬性設定 true為 ,則發出的 Microsoft 中繼語言 (MSIL) 包含局部變數的初始化。 如果設定為 false,則不會初始化局部變數,而且產生的程式代碼無法驗證。

適用於