DistanceListGetEnumerator Method

Gets an enumerator for enumeraring through the list.

Namespace:  Tekla.Structures.Datatype
Assembly:  Tekla.Structures.Datatype (in Tekla.Structures.Datatype.dll) Version: 2023.0.3
Syntax
public IEnumerator<Distance> GetEnumerator()

Return Value

Type: IEnumeratorDistance
The list enumerator.

Implements

IEnumerableTGetEnumerator
Examples
This example shows how to enumerate the Distance instances in a DistanceList.
using Tekla.Structures.Datatype;

public class Example
{
    public void Example1()
    {
        Distance[] distances = { new Distance(30.2), new Distance(2.3) };
        DistanceList distanceList = new DistanceList(distances);

        // In this example, GetEnumerator is not explicitly called, 
        // but it is implemented to support the use of foreach.
        foreach(Distance distance in distanceList)
        {
            string formattedDistance = distance.ToString();
        }

        // Indexed access is also supported. This allows the list to be enumerated in
        // any order required.
        for(int i = 0; i < distanceList.Count; i++)
        {
            string formattedDistance = distanceList[i].ToString();
        }
    }
}
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