Struct NumericDataValue<T>
A data value that contains a nullable numeric value.
public readonly struct NumericDataValue<T> : IDataValue, IFormattable, IEquatable<NumericDataValue<T>>, IConvertible where T : struct
Type Parameters
T
- Implements
- Inherited Members
- Extension Methods
Constructors
NumericDataValue(T?)
Initializes a new instance of the NumericDataValue<T> struct for a value that does not use units and or any special value formatting.
public NumericDataValue(T? value)
Parameters
value
T?The value.
NumericDataValue(T?, IDataValueDescriptor)
Initializes a new instance of the NumericDataValue<T> struct.
public NumericDataValue(T? value, IDataValueDescriptor descriptor)
Parameters
value
T?The value.
descriptor
IDataValueDescriptorThe data value descriptor.
Exceptions
- ArgumentNullException
descriptor
is null.
Properties
Descriptor
Gets the data value descriptor.
public IDataValueDescriptor Descriptor { get; }
Property Value
Inner
Gets the inner data value, or null if there is none.
public IDataValue Inner { get; }
Property Value
Remarks
This allows additional data to be added to data values, such as timestamps or validation results.
When this is set for a data value, Value and Descriptor must return the same values as those of Inner.
Value
Gets the data value.
public T? Value { get; }
Property Value
- T?
Methods
Equals(NumericDataValue<T>)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(NumericDataValue<T> other)
Parameters
other
NumericDataValue<T>An object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
ToString(string, IFormatProvider)
Formats the value of the current instance using the specified format.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
format
stringThe format to use, or null to use the default format defined for the type of the IFormattable implementation.
formatProvider
IFormatProviderThe provider to use to format the value, or null to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
Remarks
See Format(object, string, IFormatProvider) for a description of the supported formats.
Operators
operator ==(NumericDataValue<T>, NumericDataValue<T>)
Returns a value that indicates whether two specified NumericDataValue<T> values are equal.
public static bool operator ==(NumericDataValue<T> left, NumericDataValue<T> right)
Parameters
left
NumericDataValue<T>The first value to compare.
right
NumericDataValue<T>The second value to compare.
Returns
implicit operator byte(NumericDataValue<T>)
Defines an implicit conversion of a NumericDataValue<T> constant value to a byte.
public static implicit operator byte(NumericDataValue<T> value)
Parameters
value
NumericDataValue<T>The constant value.
Returns
implicit operator decimal(NumericDataValue<T>)
Defines an implicit conversion of a NumericDataValue<T> constant value to a decimal.
public static implicit operator decimal(NumericDataValue<T> value)
Parameters
value
NumericDataValue<T>The constant value.
Returns
implicit operator double(NumericDataValue<T>)
Defines an implicit conversion of a NumericDataValue<T> constant value to a double.
public static implicit operator double(NumericDataValue<T> value)
Parameters
value
NumericDataValue<T>The constant value.
Returns
implicit operator short(NumericDataValue<T>)
Defines an implicit conversion of a NumericDataValue<T> constant value to a short.
public static implicit operator short(NumericDataValue<T> value)
Parameters
value
NumericDataValue<T>The constant value.
Returns
implicit operator int(NumericDataValue<T>)
Defines an implicit conversion of a NumericDataValue<T> constant value to a int.
public static implicit operator int(NumericDataValue<T> value)
Parameters
value
NumericDataValue<T>The constant value.
Returns
implicit operator long(NumericDataValue<T>)
Defines an implicit conversion of a NumericDataValue<T> constant value to a long.
public static implicit operator long(NumericDataValue<T> value)
Parameters
value
NumericDataValue<T>The constant value.
Returns
implicit operator sbyte(NumericDataValue<T>)
Defines an implicit conversion of a NumericDataValue<T> constant value to a sbyte.
public static implicit operator sbyte(NumericDataValue<T> value)
Parameters
value
NumericDataValue<T>The constant value.
Returns
implicit operator float(NumericDataValue<T>)
Defines an implicit conversion of a NumericDataValue<T> constant value to a float.
public static implicit operator float(NumericDataValue<T> value)
Parameters
value
NumericDataValue<T>The constant value.
Returns
implicit operator ushort(NumericDataValue<T>)
Defines an implicit conversion of a NumericDataValue<T> constant value to a ushort.
public static implicit operator ushort(NumericDataValue<T> value)
Parameters
value
NumericDataValue<T>The constant value.
Returns
implicit operator uint(NumericDataValue<T>)
Defines an implicit conversion of a NumericDataValue<T> constant value to a uint.
public static implicit operator uint(NumericDataValue<T> value)
Parameters
value
NumericDataValue<T>The constant value.
Returns
implicit operator ulong(NumericDataValue<T>)
Defines an implicit conversion of a NumericDataValue<T> constant value to a ulong.
public static implicit operator ulong(NumericDataValue<T> value)
Parameters
value
NumericDataValue<T>The constant value.
Returns
operator !=(NumericDataValue<T>, NumericDataValue<T>)
Returns a value that indicates whether two specified NumericDataValue<T> values are not equal.
public static bool operator !=(NumericDataValue<T> left, NumericDataValue<T> right)
Parameters
left
NumericDataValue<T>The first value to compare.
right
NumericDataValue<T>The second value to compare.