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.

DistanceToString Method (String, IFormatProvider, DistanceUnitType)

Creates a string representation of the distance.

Namespace:  Tekla.Structures.Datatype
Assembly:  Tekla.Structures.Datatype (in Tekla.Structures.Datatype.dll) Version: 2019.0.0.0 (2019.0.0.0)
Syntax
public string ToString(
	string format,
	IFormatProvider formatProvider,
	DistanceUnitType unitType
)

Parameters

format
Type: SystemString
The format string.
formatProvider
Type: SystemIFormatProvider
The number format provider.
unitType
Type: Tekla.Structures.DatatypeDistanceUnitType
The unit type.

Return Value

Type: String
The string representation of the distance.
Exceptions
Exception Condition
ArgumentException Thrown if an invalid unit type is specified.
Examples
This example shows how to specify a number format, a format provider and a unit type when converting a Distance instance to a string.
using Tekla.Structures.Datatype;
using System.Globalization;

public class Example
{
       public void Example1()
       {
           // For this demonstration, we'll format 300.2 millimeters.
           Distance distance = new Distance(300.2);

           // We can override the unit type to display the distance in inches.
           string defaultFormatInInches = distance.ToString(null, null, Distance.UnitType.Inch);

           // With the number format and culture info we can get fully customized representation.
           string customizedFormatInInches = distance.ToString("0.00", CultureInfo.InvariantCulture,
                                           Distance.UnitType.Inch);
       }
}
See Also