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

RangeAttribute Constructor

RangeAttribute(long, long, bool, bool, int)

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

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

The minimum value.

long max

The maximum value.

bool minAllowed

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

bool maxAllowed

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

int decimalPlaces

When non-zero, interprets the min and max numbers as decimal instead of long 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(ulong, ulong, bool, bool)

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

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

The minimum value.

ulong max

The maximum value.

bool minAllowed

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

bool maxAllowed

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

RangeAttribute(double, double, bool, bool)

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

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

The minimum value.

double max

The maximum value.

bool minAllowed

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

bool maxAllowed

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

RangeAttribute(float, float, bool, bool)

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

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

The minimum value.

float max

The maximum value.

bool minAllowed

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

bool maxAllowed

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

RangeAttribute(int, int, bool, bool, int)

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

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

The minimum value.

int max

The maximum value.

bool minAllowed

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

bool maxAllowed

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

int decimalPlaces

When non-zero, interprets the min and max numbers as decimal instead of long 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(uint, uint, bool, bool)

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

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

The minimum value.

uint max

The maximum value.

bool minAllowed

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

bool maxAllowed

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

RangeAttribute(byte, sbyte, bool, bool)

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

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

The minimum value.

sbyte max

The maximum value.

bool minAllowed

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

bool maxAllowed

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

RangeAttribute(short, short, bool, bool)

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

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

The minimum value.

short max

The maximum value.

bool minAllowed

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

bool maxAllowed

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

RangeAttribute(ushort, ushort, bool, bool)

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

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

The minimum value.

ushort max

The maximum value.

bool minAllowed

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

bool maxAllowed

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