ArcGIS Pro 2.7 API Reference Guide
CreatePolyline(IEnumerable<MapPoint>,SpatialReference) Method
Example 

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

Parameters

points
Coordinates 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 points.

Return Value

Exceptions
ExceptionDescription
Incompatible spatial references.
points is null.
Example
// Use a builder convenience method or use a builder constructor.

MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 1.0);

List<MapPoint> list = new List<MapPoint>();
list.Add(startPt);
list.Add(endPt);

// Builder convenience methods don't need to run on the MCT.
Polyline polyline = PolylineBuilder.CreatePolyline(list, SpatialReferences.WGS84);

// Builder constructors need to run on the MCT.
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
  using (PolylineBuilder pb = new PolylineBuilder(list))
  {
    pb.SpatialReference = SpatialReferences.WGS84;
    Polyline polyline2 = pb.ToGeometry();
  }
});
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

PolylineBuilder Class
PolylineBuilder Members
Overload List