DynamicMethod.DefineParameter メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DynamicMethod.DefineParameter メソッドの意味・解説 

DynamicMethod.DefineParameter メソッド

メモ : このメソッドは、.NET Framework version 2.0 で新しく追加されたものです。

動的メソッドのパラメータを定義します。

名前空間: System.Reflection.Emit
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Function DefineParameter ( _
    position As Integer, _
    attributes As ParameterAttributes, _
    parameterName As String _
) As ParameterBuilder
Dim instance As DynamicMethod
Dim position As Integer
Dim attributes As ParameterAttributes
Dim parameterName As String
Dim returnValue As ParameterBuilder

returnValue = instance.DefineParameter(position, attributes, parameterName)
public ParameterBuilder DefineParameter (
    int position,
    ParameterAttributes attributes,
    string parameterName
)
public:
ParameterBuilder^ DefineParameter (
    int position, 
    ParameterAttributes attributes, 
    String^ parameterName
)
public ParameterBuilder DefineParameter (
    int position, 
    ParameterAttributes attributes, 
    String parameterName
)
public function DefineParameter (
    position : int, 
    attributes : ParameterAttributes, 
    parameterName : String
) : ParameterBuilder

パラメータ

position

パラメータ リスト内のパラメータの位置。パラメータのインデックスは 1 から始まります。最初のパラメータが 1 です。

attributes

パラメータの属性を指定する ParameterAttributes 値のビットごとの組み合わせ。

parameterName

パラメータの名前。名前は長さ 0 の文字列でもかまいません。

戻り値
パラメータを表す ParameterBuilder オブジェクト。

例外例外
例外の種類条件

ArgumentOutOfRangeException

メソッドにパラメータがありません。

または

position が 0 未満です。

または

position がメソッドのパラメータ数を超える値です。

解説解説

パラメータのパラメータ属性を設定するには、このメソッドによって返される ParameterBuilder オブジェクトを使用します。position が 0 の場合、このメソッドによって返される ParameterBuilder を使用して、動的メソッドの戻り値の型のパラメータ属性を設定できます。

CreateDelegate メソッドまたは Invoke メソッドの呼び出しによって、動的メソッドが既に完了している場合、DefineParameter メソッドは無効です。例外はスローされません。

使用例使用例

動的メソッドのパラメータ情報を定義する方法を次のコード例に示します。このコード例は、DynamicMethod クラスのトピックで取り上げているコード例の一部分です。

' Add parameter information to the dynamic method. (This is not
' necessary, but can be useful for debugging.) For each parameter,
' identified by position, supply the parameter attributes and a 
' parameter name.
Dim parameter1 As ParameterBuilder = hello.DefineParameter(
 _
     1, ParameterAttributes.In, "message")
Dim parameter2 As ParameterBuilder = hello.DefineParameter(
 _
     2, ParameterAttributes.In, "valueToReturn")
// Add parameter information to the dynamic method. (This is not
// necessary, but can be useful for debugging.) For each parameter,
// identified by position, supply the parameter attributes and a 
// parameter name.
ParameterBuilder parameter1 = hello.DefineParameter(
    1, 
    ParameterAttributes.In, 
    "message"
);
ParameterBuilder parameter2 = hello.DefineParameter(
    2, 
    ParameterAttributes.In, 
    "valueToReturn"
);
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DynamicMethod クラス
DynamicMethod メンバ
System.Reflection.Emit 名前空間



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

DynamicMethod.DefineParameter メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DynamicMethod.DefineParameter メソッドのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS