ArcGIS Pro 2.9 API Reference Guide
AddPart(IEnumerable<MapPoint>) Method
Example 

ArcGIS.Core.Geometry Namespace > MultipartBuilder<T> Class > AddPart Method : AddPart(IEnumerable<MapPoint>) Method
An enumeration of MapPoints.
Adds a part constructed from the enumeration of straight line segments constructed between the enumeration of MapPoints to the MultipartBuilder. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public virtual void AddPart( 
   IEnumerable<MapPoint> points
)
Public Overloads Overridable Sub AddPart( _
   ByVal points As IEnumerable(Of MapPoint) _
) 

Parameters

points
An enumeration of MapPoints.
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Incompatible spatial references.
points is null.
Example
List<MapPoint> firstPoints = new List<MapPoint>();
firstPoints.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
firstPoints.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
firstPoints.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
firstPoints.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));

List<MapPoint> nextPoints = new List<MapPoint>();
nextPoints.Add(MapPointBuilder.CreateMapPoint(11.0, 1.0));
nextPoints.Add(MapPointBuilder.CreateMapPoint(11.0, 2.0));
nextPoints.Add(MapPointBuilder.CreateMapPoint(12.0, 2.0));
nextPoints.Add(MapPointBuilder.CreateMapPoint(12.0, 1.0));

// Builder constructors need to run on the MCT.
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
  using (PolylineBuilder pBuilder = new PolylineBuilder(firstPoints))
  {
    pBuilder.AddPart(nextPoints);

    Polyline polyline = pBuilder.ToGeometry();
    // polyline has 2 parts

    pBuilder.RemovePart(0);
    polyline = pBuilder.ToGeometry();
    // polyline has 1 part
  }
});


// or use a builderEx constructor - doesn't need to run on MCT
PolylineBuilderEx pbuilderEx = new PolylineBuilderEx(firstPoints);
pbuilderEx.AddPart(nextPoints);
Polyline polyline2 = pbuilderEx.ToGeometry() as Polyline;
// polyline2 has 2 parts

pbuilderEx.RemovePart(0);
polyline2 = pbuilderEx.ToGeometry() as Polyline;
// polyline2 has 1 part
Requirements

Target Platforms: Windows 11, Windows 10, Windows 8.1

See Also

Reference

MultipartBuilder<T> Class
MultipartBuilder<T> Members
Overload List