ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Geometry Namespace / Segment Class / Length Property
Example

In This Topic
    Length Property (Segment)
    In This Topic
    Gets the length.
    Syntax
    public abstract double Length {get;}
    Public MustOverride ReadOnly Property Length As Double
    Example
    Enumerate the parts of a Polyline
    ReadOnlyPartCollection polylineParts = polyline.Parts;
    
    // enumerate the segments to get the length
    double len = 0;
    IEnumerator<ReadOnlySegmentCollection> segments = polylineParts.GetEnumerator();
    while (segments.MoveNext())
    {
      ReadOnlySegmentCollection seg = segments.Current;
      foreach (Segment s in seg)
      {
        len += s.Length;
    
        // perhaps do something specific per segment type
        switch (s.SegmentType)
        {
          case SegmentType.Line:
            break;
          case SegmentType.Bezier:
            break;
          case SegmentType.EllipticArc:
            break;
        }
      }
    }
    
    // or use foreach pattern
    foreach (var part in polyline.Parts)
    {
      foreach (var segment in part)
      {
        len += segment.Length;
    
        // perhaps do something specific per segment type
        switch (segment.SegmentType)
        {
          case SegmentType.Line:
            break;
          case SegmentType.Bezier:
            break;
          case SegmentType.EllipticArc:
            break;
        }
      }
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also