readonly struct DecimalMeasurement<T>

Parents

ValueType

IEquatable<DecimalMeasurement<T>>

IComparable<DecimalMeasurement<T>>

IFormattable

Brief

The class to manipulate measurements expressed in the specified units.

Parameters
T

Details

The unit of the measurement (e.g. length, weight) is defined as the parameter of this generic structure. The enumeration used as a measurement units specification must be marked using UnitAttribute and ConversionAttribute

The arithmetic operators (e.g. +, *) and comparison operators are supported.

The class supports serialization using System.Text.Json serializer and XmlSerializer as well as many 3rd party serializers such as BinaronSerializer.

Static Public Properties

BaseUnit

The base unit for the measurement

ZERO

The value with a zero measurement

Static Public Methods

Convert

Convert value from one unit to another

FromBase

Converts the value to the specified unit from a base unit.

GetUnitDefaultAccuracy

Gets the default accuracy of for the specified unit

GetUnitName

Gets the name of the unit by its code

GetUnitNames

Returns all units with their names

op_Addition

Add one measurement to another.

op_Division

Divides a measurement to a specified a constant.

op_Division

Calculate ratio between two measurements

op_Equality

Checks whether two measurements are equal

op_Explicit

Explicitly converts the a tuple to a value

op_GreaterThan

Checks whether the measurement is greater than another

op_GreaterThanOrEqual

Checks whether the measurement is greater than or equal to another

op_Implicit

Implicitly converts the value to a tuple

op_Implicit

Implicitly converts the value to an anonymous tuple

op_Implicit

Implicitly converts the value to a double value-based measurement

op_Inequality

Checks whether two measurements are not equal

op_LessThan

Checks whether the measurement is less than another

op_LessThanOrEqual

Checks whether the measurement is less than or equal another

op_Multiply

Multiples a measurement by a constant.

op_Multiply

Multiples a measurement by a constant.

op_Subtraction

Subtracts one measurement from another.

op_UnaryNegation

Negates the measurement value

op_UnaryPlus

Unary plus value

ParseUnitName

Parses the unit name

ToBase

Converts the value from the specified units to a base unit.

TryParse

Try to parse the value using the current culture

TryParse

Try to parse the value using the specified culture

Public Fields

Unit

The unit

Value

Numerical value

Public Properties

Text

The value as a string with maximum accuracy in invariant culture

Public Constructors

DecimalMeasurement

Constructor that accepts numeric value and unit

DecimalMeasurement

Constructor that accepts a tuple.

DecimalMeasurement

Constructor that accepts a anonymous tuple.

DecimalMeasurement

Constructor that accepts a text representation of a value

Public Methods

CompareTo

Compares measurement to another measurement

Equals

Checks whether the measurement equals to another measurement

Equals

Checks whether the measurement equals to another measurement

GetHashCode

Returns hash code of the value

In

Returns the value in the specified units

To

Converts the value into another unit.

ToString

Convert to string with maximum accuracy in invariant culture

ToString

Convert to string with maximum accuracy in the specified culture

ToString

Convert to string with specified format

back