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設定されている場合、ローカル変数は初期化されず、生成されたコードは検証できません。

適用対象