Description
Provides helper methods for a quantity.
Public Methods
Add | Adds the value from the IAgQuantity interface to this interface. Returns a new IAgQuantity. The dimensions must be similar. |
ConvertToUnit | Changes the value in this quantity to the specified unit. |
DivideQty | Divides the value from the IAgQuantity interface to this interface. The dimensions must be similar. |
MultiplyQty | Multiplies the value from the IAgQuantity interface to this interface. Returns a new IAgQuantity. The dimensions must be similar. |
Subtract | Subtracts the value from the IAgQuantity interface to this interface. Returns a new IAgQuantity. The dimensions must be similar. |
Public Properties
Dimension | Gets the name of the dimension. |
Unit | Get the current Unit abbreviation. |
Value | Gets or sets the current value. |
Example
Calculate quantity addition (with IAgQuantity)
[C#] |
---|
// Create a quantity representing a 3.1 mile/ 5 km fun run race
IAgQuantity race3mi = root.ConversionUtility.NewQuantity("Distance", "mi", 3.1);
IAgQuantity race5km = root.ConversionUtility.NewQuantity("Distance", "km", 5);
// Add the two 3.1 mile/ 5 km runs
IAgQuantity race10km = race5km.Add(race3mi);
Console.Write("The {0} {1} race is also called a ", race10km.Value, race10km.Unit);
// Convert 10k run to 6.2 mile run internally within the quantity
race10km.ConvertToUnit("mi");
Console.WriteLine("{0} {1} race", race10km.Value, race10km.Unit);
|
|
Calculate quantity addition (with IAgQuantity)
[Visual Basic .NET] |
---|
' Create a quantity representing a 3.1 mile/ 5 km fun run race
Dim race3mi As IAgQuantity = root.ConversionUtility.NewQuantity("Distance", "mi", 3.1)
Dim race5km As IAgQuantity = root.ConversionUtility.NewQuantity("Distance", "km", 5)
' Add the two 3.1 mile/ 5 km runs
Dim race10km As IAgQuantity = race5km.Add(race3mi)
Console.Write("The {0} {1} race is also called a ", race10km.Value, race10km.Unit)
' Convert 10k run to 6.2 mile run internally within the quantity
race10km.ConvertToUnit("mi")
Console.WriteLine("{0} {1} race", race10km.Value, race10km.Unit)
|
|