ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Geometry Namespace / ReadOnlyPointCollection Class / CopyPointsToList Method
The index of the first point to copy.
The number of points to copy.
The list into which the points are copied. Each returned point in the list has a null spatial reference.
Example

In This Topic
    CopyPointsToList Method
    In This Topic
    Copies the MapPoints in this list to the given list of MapPoints.
    Syntax
    Public Sub CopyPointsToList( _
       ByVal startIndex As Integer, _
       ByVal pointCount As Integer, _
       ByRef points As ICollection(Of MapPoint) _
    ) 
    public void CopyPointsToList( 
       int startIndex,
       int pointCount,
       ref ICollection<MapPoint> points
    )

    Parameters

    startIndex
    The index of the first point to copy.
    pointCount
    The number of points to copy.
    points
    The list into which the points are copied. Each returned point in the list has a null spatial reference.
    Exceptions
    ExceptionDescription
    points is null.
    pointCount is less than zero.
    startIndex + pointCount is greater than the actual number of points in this list.
    Remarks
    Use this method to get a list of points of a geometry on which low-level calculations may be performed. Performance may be improved by reusing the same list for each geometry. For optimal performance, the points collection should have a capacity greater than or equal to the number of points that are to be copied.
    Example
    Get the points of a Polyline
    {
      // get the points as a readonly Collection
      //Refer to the initialization region for polyline creation
      ReadOnlyPointCollection pts = polyline.Points;
      int numPts = polyline.PointCount;
    
      // OR   get an enumeration of the points
      IEnumerator<MapPoint> enumPts = polyline.Points.GetEnumerator();
    
      // OR   get the point coordinates as a readonly list of Coordinate2D
      IReadOnlyList<Coordinate2D> coordinates = polyline.Copy2DCoordinatesToList();
    
      // OR   get the point coordinates as a readonly list of Coordinate3D
      IReadOnlyList<Coordinate3D> coordinates3D = polyline.Copy3DCoordinatesToList();
    
      // OR   get a subset of the collection as Coordinate2D using preallocated memory
    
      IList<Coordinate2D> coordinate2Ds = new List<Coordinate2D>(10);   // allocate some space
      ICollection<Coordinate2D> subsetCoordinates2D = coordinate2Ds;    // assign
      pts.Copy2DCoordinatesToList(1, 2, ref subsetCoordinates2D);       // copy 2 elements from index 1 into the allocated list
                                                                        // coordinate2Ds.Count = 2
                                                                        // do something with the coordinate2Ds
    
      // without allocating more space, obtain a different set of coordinates
      pts.Copy2DCoordinatesToList(5, 9, ref subsetCoordinates2D);       // copy 9 elements from index 5 into the allocated list
                                                                        // coordinate2Ds.Count = 9
    
    
      // OR   get a subset of the collection as Coordinate3D using preallocated memory
    
      IList<Coordinate3D> coordinate3Ds = new List<Coordinate3D>(15);   // allocate some space
      ICollection<Coordinate3D> subsetCoordinates3D = coordinate3Ds;    // assign
      pts.Copy3DCoordinatesToList(3, 5, ref subsetCoordinates3D);       // copy 5 elements from index 3 into the allocated list
                                                                        // coordinate3Ds.Count = 5
    
    
      // OR   get a subset of the collection as MapPoint using preallocated memory
    
      IList<MapPoint> mapPoints = new List<MapPoint>(7);   // allocate some space
      ICollection<MapPoint> subsetMapPoint = mapPoints;    // assign
      pts.CopyPointsToList(1, 4, ref subsetMapPoint);      // copy 4 elements from index 1 into the allocated list
                                                           // mapPoints.Count = 4
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also