ArcGIS Pro 2.8 API Reference Guide
CreatePolyline(IEnumerable<Segment>,SpatialReference) Method
Example 

ArcGIS.Core.Geometry Namespace > PolylineBuilder Class > CreatePolyline Method : CreatePolyline(IEnumerable<Segment>,SpatialReference) Method
Segments to create the polyline.
(Optional) The SpatialReference. The default value is null. If spatialReference is null, then the spatial reference will be inherited from segments.
Convenience method to create a new instance of the Polyline class.
Syntax
Public Overloads Shared Function CreatePolyline( _
   ByVal segments As IEnumerable(Of Segment), _
   Optional ByVal spatialReference As SpatialReference _
) As Polyline

Parameters

segments
Segments to create the polyline.
spatialReference
(Optional) The SpatialReference. The default value is null. If spatialReference is null, then the spatial reference will be inherited from segments.

Return Value

Exceptions
ExceptionDescription
Incompatible spatial references.
segments is null.
Example
ICollection<Segment> collection = new List<Segment>();
polyline.GetAllSegments(ref collection);
int numSegments = collection.Count;    // = 10

IList<Segment> iList = collection as IList<Segment>;
for (int i = 0; i < numSegments; i++)
{
  // do something with iList[i]
}

// use the segments to build another polyline
Polyline polylineFromSegments = PolylineBuilder.CreatePolyline(collection);
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

PolylineBuilder Class
PolylineBuilder Members
Overload List