DynamicMethod.DefineParameter(Int32, ParameterAttributes, String) Método

Definición

Define un parámetro del método dinámico.

public:
 System::Reflection::Emit::ParameterBuilder ^ DefineParameter(int position, System::Reflection::ParameterAttributes attributes, System::String ^ parameterName);
public System.Reflection.Emit.ParameterBuilder? DefineParameter (int position, System.Reflection.ParameterAttributes attributes, string? parameterName);
public System.Reflection.Emit.ParameterBuilder DefineParameter (int position, System.Reflection.ParameterAttributes attributes, string parameterName);
member this.DefineParameter : int * System.Reflection.ParameterAttributes * string -> System.Reflection.Emit.ParameterBuilder
Public Function DefineParameter (position As Integer, attributes As ParameterAttributes, parameterName As String) As ParameterBuilder

Parámetros

position
Int32

Posición del parámetro en la lista de parámetros. Los parámetros se indizan empezando por el número 1 para el primer parámetro.

attributes
ParameterAttributes

Combinación bit a bit de valores ParameterAttributes que especifica los atributos del parámetro.

parameterName
String

El nombre del parámetro. El nombre puede ser una cadena de longitud cero.

Devoluciones

Siempre devuelve null.

Excepciones

El método no tiene parámetros.

o bien

position es menor que 0.

o bien

position es mayor que el número de los parámetros del método.

Ejemplos

En el ejemplo de código siguiente se muestra cómo definir información de parámetros para un método dinámico. Este ejemplo de código es parte de un ejemplo mayor proporcionado para la clase 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.
hello->DefineParameter(1, ParameterAttributes::In, "message");
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.
hello.DefineParameter(1, ParameterAttributes.In, "message");
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.
hello.DefineParameter(1, ParameterAttributes.In, "message")
hello.DefineParameter(2, ParameterAttributes.In, "valueToReturn")

Comentarios

Si position es 0, el DefineParameter método hace referencia al valor devuelto. Establecer la información del parámetro no tiene ningún efecto en el valor devuelto.

Si el método dinámico ya se ha completado, llamando al CreateDelegate método o Invoke , el DefineParameter método no tiene ningún efecto. No se inicia ninguna excepción.

Se aplica a