DistanceListToString Method (String, IFormatProvider, DistanceUnitType)

Returns the string representation of the distance list.

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

Parameters

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

Return Value

Type: String
The string representation of the distance list.
Examples
This example shows how to override the number format, the format provider and the unit type when formatting a DistanceList instance.
using Tekla.Structures.Datatype;
using System.Globalization;

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

           // UseFractionalFormat controls whether the feet and inches are formatted
           // using the fractional representation. The default value is false which
           // causes the feet and inches to be represented as decimal numbers.
           Distance.UseFractionalFormat = false;

           // UseUnitsInDecimalString controls whether the unit type is shown in the
           // decimal string representation. The default is false.
           Distance.UseUnitsInDecimalString = false;

           // We'll use this distance list to demonstrate the formatting.
           DistanceList distanceList = new DistanceList(new Distance[]
                                                       {
                                                           new Distance(30.2),
                                                           new Distance(30.2),
                                                           new Distance(30.2),
                                                           new Distance(50),
                                                           new Distance(2.3),
                                                           new Distance(2.3),
                                                       });

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

           // We can also combine the above with the number format and culture info to get fully customized representation.
           string TeklaStructuresFormatWithPrecicionInInches = distanceList.ToString("0.00", CultureInfo.InvariantCulture, Distance.UnitType.Inch);
       }
}
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