DistanceParse Method (String, IFormatProvider)

Parses a distance from a string representation using the current unit type and the given culture.

Namespace:  Tekla.Structures.Datatype
Assembly:  Tekla.Structures.Datatype (in Tekla.Structures.Datatype.dll) Version: 2023.0.3
Syntax
public static Distance Parse(
	string text,
	IFormatProvider formatProvider
)

Parameters

text
Type: SystemString
The text to parse.
formatProvider
Type: SystemIFormatProvider
The number format provider.

Return Value

Type: Distance
The representation of the specified distance.
Exceptions
ExceptionCondition
FormatExceptionThrown if the text does not represent a distance.
Examples
This example shows how to specify a format provider when parsing a Distance instance from a string.
using Tekla.Structures.Datatype;
using System.Globalization;

public class Example
{
       public void Example1()
       {
           // Current unit type controls the default unit type used in parsing.
           // The default unit is millimeter.
           Distance.CurrentUnitType = Distance.UnitType.Millimeter;

           // Tekla Structures uses dot as the decimal separator in all locales.
           // This will be parsed as 30.2 millimeters.
           Distance distanceInMillimeters = Distance.Parse("30.2", CultureInfo.InvariantCulture);

           // If the distance contains the unit, the distance is converted automatically.
           // This will be parsed as 30.2 meters.
           Distance distanceInMeters = Distance.Parse("30.2m", CultureInfo.InvariantCulture);
       }
}
See Also
Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.
Previous
Next