DimensionfulQuantityExtensionsCheckUnitCompatibleWith Method |
Checks whether the quantity
x has the expected
expectedUnit, and if not, throws an
ArgumentException.
Namespace: Altaxo.UnitsAssembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3448.0 (4.8.3448.0)
Syntaxpublic static void CheckUnitCompatibleWith(
this DimensionfulQuantity x,
IUnit expectedUnit,
string valueName = ""
)
Parameters
- x DimensionfulQuantity
- The dimensionful quantity to check.
- expectedUnit IUnit
- The expected unit the quantity should have.
- valueName String (Optional)
- Name of the value x. When compiled with C# 10 or later the caller argument expression will be supplied automatically.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
DimensionfulQuantity. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Exceptions| Exception | Condition |
|---|
| ArgumentException | Argument '{valueName}' has a unit {x.Unit} that is not compatible with '{expectedUnit}'. |
Remarks
This helper is intended to validate that the runtime unit of
x is compatible with the provided
expectedUnit (i.e. both share the same SI base dimensions). If they are incompatible an
ArgumentException is thrown identifying the argument name and the incompatible units.
See Also