Open sandboxFocus

Method AddTypeParameter

AddTypeParameter(string)

Adds a generic parameter to the type.

Declaration
ITypeParameterBuilder AddTypeParameter(string name)
Parameters
Type Name Description
string name

Name of the generic parameter.

Returns
Type Description
ITypeParameterBuilder

An ITypeParameterBuilder that allows you to further build the new parameter.

AddTypeParameter(ITypeParameter, bool)

Adds a type parameter that copies an existing type parameter: its name, its variance, its kind constraints and its type constraints.

Declaration
ITypeParameterBuilder AddTypeParameter(ITypeParameter prototype, bool includeCustomAttributes = false)
Parameters
Type Name Description
ITypeParameter prototype

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

bool includeCustomAttributes

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

Returns
Type Description
ITypeParameterBuilder

An ITypeParameterBuilder that allows you to change the copy.

Remarks

The builder records the copy. In the type constraints of the copy, and in the types of the type parameters and parameters that are copied afterwards, a reference to prototype is replaced by a reference to the copy. Copy the type parameters before the parameters that use them.

Exceptions
Type Condition
ArgumentException

A type parameter of the same name already exists.