Open sandboxFocus

Method AddParameter

AddParameter(string, IType, RefKind, TypedConstant?)

Appends a parameter to the method.

Declaration
IParameterBuilder AddParameter(string name, IType type, RefKind refKind = RefKind.None, TypedConstant? defaultValue = null)
Parameters
Type Name Description
string name

Parameter name.

IType type

Parameter type.

RefKind refKind

out, ref...

TypedConstant? defaultValue

Default value.

Returns
Type Description
IParameterBuilder

A IParameterBuilder that allows you to further build the new parameter.

AddParameter(string, Type, RefKind, TypedConstant?)

Appends a parameter to the method.

Declaration
IParameterBuilder AddParameter(string name, Type type, RefKind refKind = RefKind.None, TypedConstant? defaultValue = null)
Parameters
Type Name Description
string name

Parameter name.

Type type

Parameter type.

RefKind refKind

out, ref...

TypedConstant? defaultValue

Default value.

Returns
Type Description
IParameterBuilder

A IParameterBuilder that allows you to further build the new parameter.

AddParameter(IParameter, bool, bool)

Appends a parameter that copies an existing parameter: its name, its type and its reference kind.

Declaration
IParameterBuilder AddParameter(IParameter prototype, bool includeCustomAttributes = false, bool includeDefaultValues = false)
Parameters
Type Name Description
IParameter prototype

The parameter to copy, typically a parameter of another method.

bool includeCustomAttributes

A value indicating whether the custom attributes of prototype are copied.

bool includeDefaultValues

A value indicating whether the default value and the params modifier of prototype are copied.

Returns
Type Description
IParameterBuilder

An IParameterBuilder that allows you to change the copy.

Remarks

In the type of the copy, a reference to a type parameter that was copied with AddTypeParameter(ITypeParameter, bool) is replaced by a reference to its copy. The this modifier is never copied.

Exceptions
Type Condition
ArgumentException

A parameter of the same name already exists.