Class NumericDataValueDescriptor
The default INumericDataValueDescriptor implementation.
public class NumericDataValueDescriptor : DataValueDescriptor, INumericDataValueDescriptor, IDataValueDescriptor
- Inheritance
-
NumericDataValueDescriptor
- Implements
- Inherited Members
Remarks
Values used by this descriptor are expected to implement IConvertible.
Constructors
NumericDataValueDescriptor(int, string)
Initializes a new instance of the NumericDataValueDescriptor class.
public NumericDataValueDescriptor(int precision, string units)
Parameters
precision
intThe precision of data values, as the number of digits after the decimal point, where negative values indicate the number of digits before the decimal point.
units
stringThe units of measurement, or null if there are none.
Properties
Precision
Gets the precision, or significant digits, as the number of digits to the right of the decimal point. A negative number indicates digits to the left.
public int Precision { get; }
Property Value
Remarks
For example, for the value 2914.24785217:
- 2 means values are significant to the nearest hundredth, so the value would normally be displayed as: 2,914.25
- 0 means values are significant to the nearest whole number, so the value would normally be displayed as: 2,914
- -3 means values are significant to the nearest thousand, so the value would normally be displayed as: 3,000
- 2914.24785217 would be used in calculations, but Precision can be used along with the Precision of other values in the calculation to determine what the resulting value precision should be.
Methods
Format(object, string, IFormatProvider)
Formats a data value using the specified format.
public override string Format(object value, string format, IFormatProvider formatProvider)
Parameters
value
objectThe value to format.
format
stringThe format to use (see remarks), or null to use the default display format ("D").
formatProvider
IFormatProviderThe provider to use to format the value, or null to obtain the format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
Remarks
The following format values are valid for format
:
G
- The general format, which is the same as D
.
D
- The display format, which includes the formatted data value along with the units, if it has any. Example: 1,234.5 psi
V
- The value format, which is the display format without units. Example: 1,234.5
S
- The serialization format. Note that formatProvider
is ignored (InvariantCulture is always used). Example: 1234.5
Exceptions
- FormatException
The format string is not supported.