API Reference

Detailed and full API reference helps you master Tekla development

This is the most recent version of Tekla Open API.
For older versions, please visit Tekla Warehouse.

Meta.Microsoft.Help.Id
M:Tekla.Structures.Datatype.Distance.TryParse(System.String,Tekla.Structures.Datatype.Distance@)

DistanceTryParse Method (String, Distance)

Attempts to parse a distance from a string representation using the current units.

Namespace:  Tekla.Structures.Datatype
Assembly:  Tekla.Structures.Datatype (in Tekla.Structures.Datatype.dll) Version: 2020.0.0.0 (2020.0.55582.0)
Syntax
public static bool TryParse(
	string text,
	out Distance result
)

Parameters

text
Type: SystemString
The text to parse.
result
Type: Tekla.Structures.DatatypeDistance
The output variable for the result.

Return Value

Type: Boolean
A boolean value indicating whether the operation succeeded.
Examples
This example shows how to attempt to parse a Distance instance from a string.
using Tekla.Structures.Datatype;

public class Example
{
       public void Example1()
       {
           Distance.CurrentUnitType = Distance.UnitType.Millimeter;

           // If the string can not be parsed, an exception is thrown. To prevent the
           // exception we can use the Distance.TryParse instead. We'll use this variable
           // to hold the parsed value.
           Distance distance;

           // Distance.TryParse works just like the Distance.Parse method, except the method
           // returns a boolean value indicating whether the string was parsed and takes an
           // output variable for holding the result.
           bool parsed = Distance.TryParse("3", out distance);
       }
}
See Also