Struct Weight
Represents weight with unit type.
All operations are done with precision of 1 milligram
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Azos.dll
Syntax
public struct Weight : IEquatable<Weight>, IComparable<Weight>, IJSONWritable
Constructors
Weight(Decimal, Weight.UnitType)
Declaration
public Weight(decimal value, Weight.UnitType unit)
Parameters
Fields
G_IN_KG
Declaration
public const decimal G_IN_KG = 1000.0M
Field Value
Type |
Description |
System.Decimal |
|
G_IN_LB
Declaration
public const decimal G_IN_LB = 453.592M
Field Value
Type |
Description |
System.Decimal |
|
G_IN_OZ
Declaration
public const decimal G_IN_OZ = 28.3495M
Field Value
Type |
Description |
System.Decimal |
|
Unit
Declaration
public readonly Weight.UnitType Unit
Field Value
Value
Declaration
public readonly decimal Value
Field Value
Type |
Description |
System.Decimal |
|
VALUE_PRECISION
Declaration
public const int VALUE_PRECISION = 3
Field Value
Type |
Description |
System.Int32 |
|
ValueInGrams
Declaration
public readonly decimal ValueInGrams
Field Value
Type |
Description |
System.Decimal |
|
Properties
UnitName
Declaration
public string UnitName { get; }
Property Value
Type |
Description |
System.String |
|
Methods
CompareTo(Weight)
Declaration
public int CompareTo(Weight other)
Parameters
Type |
Name |
Description |
Weight |
other |
|
Returns
Type |
Description |
System.Int32 |
|
Convert(Weight.UnitType)
Declaration
public Weight Convert(Weight.UnitType toUnit)
Parameters
Returns
Equals(Weight)
Declaration
public bool Equals(Weight other)
Parameters
Type |
Name |
Description |
Weight |
other |
|
Returns
Type |
Description |
System.Boolean |
|
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
System.ValueType.Equals(System.Object)
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
System.ValueType.GetHashCode()
Parse(String)
Declaration
public static Weight Parse(string val)
Parameters
Type |
Name |
Description |
System.String |
val |
|
Returns
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.ValueType.ToString()
TryParse(String, out Nullable<Weight>)
Declaration
public static bool TryParse(string val, out Weight? result)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<Weight> |
result |
|
Returns
Type |
Description |
System.Boolean |
|
ValueIn(Weight.UnitType)
Declaration
public decimal ValueIn(Weight.UnitType toUnit)
Parameters
Returns
Type |
Description |
System.Decimal |
|
WriteAsJSON(TextWriter, Int32, JSONWritingOptions)
Declaration
public void WriteAsJSON(TextWriter wri, int nestingLevel, JSONWritingOptions options = null)
Parameters
Type |
Name |
Description |
System.IO.TextWriter |
wri |
|
System.Int32 |
nestingLevel |
|
JSONWritingOptions |
options |
|
Operators
Addition(Weight, Weight)
Declaration
public static Weight operator +(Weight obj1, Weight obj2)
Parameters
Returns
Division(Weight, Decimal)
Declaration
public static Weight operator /(Weight obj1, decimal obj2)
Parameters
Type |
Name |
Description |
Weight |
obj1 |
|
System.Decimal |
obj2 |
|
Returns
Equality(Weight, Weight)
Declaration
public static bool operator ==(Weight obj1, Weight obj2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
GreaterThan(Weight, Weight)
Declaration
public static bool operator>(Weight obj1, Weight obj2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
GreaterThanOrEqual(Weight, Weight)
Declaration
public static bool operator >=(Weight obj1, Weight obj2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Inequality(Weight, Weight)
Declaration
public static bool operator !=(Weight obj1, Weight obj2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
LessThan(Weight, Weight)
Declaration
public static bool operator <(Weight obj1, Weight obj2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
LessThanOrEqual(Weight, Weight)
Declaration
public static bool operator <=(Weight obj1, Weight obj2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Multiply(Weight, Decimal)
Declaration
public static Weight operator *(Weight obj1, decimal obj2)
Parameters
Type |
Name |
Description |
Weight |
obj1 |
|
System.Decimal |
obj2 |
|
Returns
Subtraction(Weight, Weight)
Declaration
public static Weight operator -(Weight obj1, Weight obj2)
Parameters
Returns
Implements
System.IEquatable<T>
System.IComparable<T>
Extension Methods