MetalamaAPI documentationPatterns APIMetalama.​Patterns.​ContractsRange­AttributeRange­Attribute
Open sandboxFocus

RangeAttribute Constructor

RangeAttribute(Int64, Int64, Boolean, Boolean, Int32)

Initializes a new instance of the RangeAttribute class specifying bounds of type System.Int64.

Declaration
public RangeAttribute(long min, long max, bool minAllowed = true, bool maxAllowed = true, int decimalPlaces = 0)
Parameters
Type Name Description
System.Int64 min

The minimum value.

System.Int64 max

The maximum value.

System.Boolean minAllowed

Determines if the min value is allowed (i.e. if the inequality is >= instead of >.

System.Boolean maxAllowed

Determines if the max value is allowed (i.e. if the inequality is <= instead of <.

System.Int32 decimalPlaces

When non-zero, interprets the min and max numbers as System.Decimal instead of System.Int64 by adding a decimal point at the specified position. For instance, if min is set to 1234 and decimalPlaces is set to 3, the min parameter will be reinterpreted as 1.234m.

RangeAttribute(UInt64, UInt64, Boolean, Boolean)

Initializes a new instance of the RangeAttribute class specifying bounds of type System.UInt64.

Declaration
public RangeAttribute(ulong min, ulong max, bool minAllowed = true, bool maxAllowed = true)
Parameters
Type Name Description
System.UInt64 min

The minimum value.

System.UInt64 max

The maximum value.

System.Boolean minAllowed

Determines if the min value is allowed (i.e. if the inequality is >= instead of >.

System.Boolean maxAllowed

Determines if the max value is allowed (i.e. if the inequality is <= instead of <.

RangeAttribute(Double, Double, Boolean, Boolean)

Initializes a new instance of the RangeAttribute class specifying bounds of type System.Double.

Declaration
public RangeAttribute(double min, double max, bool minAllowed = true, bool maxAllowed = true)
Parameters
Type Name Description
System.Double min

The minimum value.

System.Double max

The maximum value.

System.Boolean minAllowed

Determines if the min value is allowed (i.e. if the inequality is >= instead of >.

System.Boolean maxAllowed

Determines if the max value is allowed (i.e. if the inequality is <= instead of <.

RangeAttribute(Single, Single, Boolean, Boolean)

Initializes a new instance of the RangeAttribute class specifying bounds of type System.Single.

Declaration
public RangeAttribute(float min, float max, bool minAllowed = true, bool maxAllowed = true)
Parameters
Type Name Description
System.Single min

The minimum value.

System.Single max

The maximum value.

System.Boolean minAllowed

Determines if the min value is allowed (i.e. if the inequality is >= instead of >.

System.Boolean maxAllowed

Determines if the max value is allowed (i.e. if the inequality is <= instead of <.

RangeAttribute(Int32, Int32, Boolean, Boolean, Int32)

Initializes a new instance of the RangeAttribute class specifying bounds of type System.Int32.

Declaration
public RangeAttribute(int min, int max, bool minAllowed = true, bool maxAllowed = true, int decimalPlaces = 0)
Parameters
Type Name Description
System.Int32 min

The minimum value.

System.Int32 max

The maximum value.

System.Boolean minAllowed

Determines if the min value is allowed (i.e. if the inequality is >= instead of >.

System.Boolean maxAllowed

Determines if the max value is allowed (i.e. if the inequality is <= instead of <.

System.Int32 decimalPlaces

When non-zero, interprets the min and max numbers as System.Decimal instead of System.Int64 by adding a decimal point at the specified position. For instance, if min is set to 1234 and decimalPlaces is set to 3, the min parameter will be reinterpreted as 1.234m.

RangeAttribute(UInt32, UInt32, Boolean, Boolean)

Initializes a new instance of the RangeAttribute class specifying bounds of type System.UInt32.

Declaration
public RangeAttribute(uint min, uint max, bool minAllowed = true, bool maxAllowed = true)
Parameters
Type Name Description
System.UInt32 min

The minimum value.

System.UInt32 max

The maximum value.

System.Boolean minAllowed

Determines if the min value is allowed (i.e. if the inequality is >= instead of >.

System.Boolean maxAllowed

Determines if the max value is allowed (i.e. if the inequality is <= instead of <.

RangeAttribute(Byte, SByte, Boolean, Boolean)

Initializes a new instance of the RangeAttribute class specifying bounds of type System.Byte.

Declaration
public RangeAttribute(byte min, sbyte max, bool minAllowed = true, bool maxAllowed = true)
Parameters
Type Name Description
System.Byte min

The minimum value.

System.SByte max

The maximum value.

System.Boolean minAllowed

Determines if the min value is allowed (i.e. if the inequality is >= instead of >.

System.Boolean maxAllowed

Determines if the max value is allowed (i.e. if the inequality is <= instead of <.

RangeAttribute(Int16, Int16, Boolean, Boolean)

Initializes a new instance of the RangeAttribute class specifying bounds of type System.Int16.

Declaration
public RangeAttribute(short min, short max, bool minAllowed = true, bool maxAllowed = true)
Parameters
Type Name Description
System.Int16 min

The minimum value.

System.Int16 max

The maximum value.

System.Boolean minAllowed

Determines if the min value is allowed (i.e. if the inequality is >= instead of >.

System.Boolean maxAllowed

Determines if the max value is allowed (i.e. if the inequality is <= instead of <.

RangeAttribute(UInt16, UInt16, Boolean, Boolean)

Initializes a new instance of the RangeAttribute class specifying bounds of type System.UInt16.

Declaration
public RangeAttribute(ushort min, ushort max, bool minAllowed = true, bool maxAllowed = true)
Parameters
Type Name Description
System.UInt16 min

The minimum value.

System.UInt16 max

The maximum value.

System.Boolean minAllowed

Determines if the min value is allowed (i.e. if the inequality is >= instead of >.

System.Boolean maxAllowed

Determines if the max value is allowed (i.e. if the inequality is <= instead of <.