Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Do you have gauge pressure measurement in default units? #1495

Answered by lipchev
may3rd asked this question in Q&A
Discussion options

I just wonder if you already have the gauge pressure measurement?

You must be logged in to vote

You can parse and use the UnitConverter on the Pressure type, which is the standard IQuantity. The ReferencePressure is a wrapper that doesn't implement the IQuantity interface (as it contains more than a Unit and Value).

Replies: 1 comment 2 replies

Comment options

We have a wrapper for Pressure, see

public Pressure Gauge => As(PressureReference.Gauge);
You must be logged in to vote
2 replies
Comment options

Can it use parser to create IQuantity to use by UnitConverter? I write the VB.Net code as below. Please give me an advise. Thank you.

Public Function ConvertUnit(value As Double, fromUnit As String, toUnit As String
) As Double
 Try
 ' Dynamically parse the quantity type based on the fromUnit
 Dim inputQuantity As IQuantity = UnitsNet.Quantity.FromUnitAbbreviation(value, fromUnit)
 Dim type = inputQuantity.GetType().Name
 Dim convertedValue = UnitConverter.ConvertByAbbreviation(value, type, fromUnit, toUnit)
 Return convertedValue
 Catch ex As Exception
 Return ex.Message
 End Try
End Function
Comment options

lipchev Jan 8, 2025
Collaborator

You can parse and use the UnitConverter on the Pressure type, which is the standard IQuantity. The ReferencePressure is a wrapper that doesn't implement the IQuantity interface (as it contains more than a Unit and Value).

Answer selected by may3rd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /