Open sandboxFocus

Method AddPositionalParameter

AddPositionalParameter(string, IType, TypedConstant?)

Appends a positional parameter to the record, which declares a parameter of the primary constructor and a public init-only property of the same name and type.

Declaration
IParameterBuilder AddPositionalParameter(string name, IType type, TypedConstant? defaultValue = null)
Parameters
Type Name Description
string name

The name of the parameter, which is also the name of the property it declares.

IType type

The type of the parameter.

TypedConstant? defaultValue

The default value of the parameter, or null when it has none.

Returns
Type Description
IParameterBuilder

An IParameterBuilder that allows you to further build the new parameter, in particular to add custom attributes to it.

Remarks

A record that has at least one positional parameter is a positional record, and the compiler synthesizes a Deconstruct method for it. A record that has none declares no parameter list, and DeconstructMethod is then null on the introduced type.

AddPositionalParameter(string, Type, TypedConstant?)

Appends a positional parameter to the record, which declares a parameter of the primary constructor and a public init-only property of the same name and type.

Declaration
IParameterBuilder AddPositionalParameter(string name, Type type, TypedConstant? defaultValue = null)
Parameters
Type Name Description
string name

The name of the parameter, which is also the name of the property it declares.

Type type

The type of the parameter.

TypedConstant? defaultValue

The default value of the parameter, or null when it has none.

Returns
Type Description
IParameterBuilder

An IParameterBuilder that allows you to further build the new parameter, in particular to add custom attributes to it.

Remarks

A record that has at least one positional parameter is a positional record, and the compiler synthesizes a Deconstruct method for it. A record that has none declares no parameter list, and DeconstructMethod is then null on the introduced type.