MethodBuilder.DefineParameter Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Sets the parameter attributes and the name of a parameter of this method, or of the return value of this method. Returns a ParameterBuilder that can be used to apply custom attributes.

Namespace:  System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Function DefineParameter ( _
    position As Integer, _
    attributes As ParameterAttributes, _
    strParamName As String _
) As ParameterBuilder
[SecuritySafeCriticalAttribute]
public ParameterBuilder DefineParameter(
    int position,
    ParameterAttributes attributes,
    string strParamName
)

Parameters

  • position
    Type: System.Int32
    The position of the parameter in the parameter list. Parameters are indexed beginning with the number 1 for the first parameter; the number 0 represents the return value of the method.
  • strParamName
    Type: System.String
    The name of the parameter. The name can be the null string.

Return Value

Type: System.Reflection.Emit.ParameterBuilder
Returns a ParameterBuilder object that represents a parameter of this method or the return value of this method.

Exceptions

Exception Condition
ArgumentOutOfRangeException

The method has no parameters.

-or-

position is less than zero.

-or-

position is greater than the number of the method's parameters.

InvalidOperationException

The containing type was previously created using CreateType.

-or-

For the current method, the IsGenericMethod property is true, but the IsGenericMethodDefinition property is false.

Remarks

The ParameterBuilder object returned by this method can be used to set the default value for a parameter or to apply custom attributes.

Parameter numbering begins with 1, so position is 1 for the first parameter. If position is zero, this method affects the return value.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.