Attempts to convert a measurement from this Unit to a different specified Unit of the same UnitType, indicating success by the return value.

Namespace:  ESRI.ArcGISExplorer.Geometry

Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public bool TryConvert(
	double inMeasurement,
	Unit outUnit,
	out double result
)
Visual Basic (Declaration)
Public Function TryConvert ( _
	inMeasurement As Double, _
	outUnit As Unit, _
	<OutAttribute> ByRef result As Double _
) As Boolean

Parameters

inMeasurement
Type: System..::.Double

The measurement to convert.
outUnit
Type: ESRI.ArcGISExplorer.Geometry..::.Unit

The Units that inMeasurement should be converted to.
result
Type: System..::.Double %

The converted measurement.

Return Value

trueTruetruetrue (True in Visual Basic) if the measurement was successfully converted; otherwise, falseFalsefalsefalse (False in Visual Basic).

Remarks

This method provides an alternative to the Convert(Double, Unit) method - it indicates failure by the return boolean value instead of throwing an exception. A successful measurement conversion is indicated by the return value of trueTruetruetrue (True in Visual Basic), in which case the conversion result is available in the result out parameter.

A TryConvert call will fail if you are attempting to convert a measurement to a different UnitType. This includes the case of converting between angular units and linear units - the reason for this limitation is that angular units may change in terms of the linear distance they represent depending on where they are located on the earth. If you wish to convert from an angular to a linear measurement, then you can use the GeodesicUtilities.Length method to specify a particular Polyline (which specifies the location on the earth) to return a measurement in linear units. Similarly you can use the GeodesicUtilities.Area methods to convert the area of a specific Polygon or Envelope from an angular to an area unit.

See Also