ArcGIS Pro 2.6 API Reference Guide
Extend Method (GeometryEngine)
Example 

ArcGIS.Core.Geometry Namespace > GeometryEngine Class : Extend Method
The polyline to be extended.
The polyline to extend to.
The type of extend operation to perform.
Performs the extend operation on a polyline using a polyline as the extender. The output polyline will have the first and last segment of each part extended to the extender if the segments can be interpolated to intersect the extender. In the case that the segments can be extended to multiple segments of the extender, the shortest extension is chosen. Only end points for parts that are not shared by the end points of other parts will be extended. If the polyline cannot be extended by the input extender, then a null will be returned.
Syntax
Public Function Extend( _
   ByVal polyline As Polyline, _
   ByVal extender As Polyline, _
   ByVal ExtendFlags As ExtendFlags _
) As Polyline

Parameters

polyline
The polyline to be extended.
extender
The polyline to extend to.
ExtendFlags
The type of extend operation to perform.

Return Value

The extended polyline.
Exceptions
ExceptionDescription
Either polyline or extender or both are null or empty.
Incompatible spatial references between the input geometries.
Throws InvalidOperationException if both ExtendFlags.NoEndAttributes and ExtendFlags.KeepEndAttributes flags are sent together.
Remarks
Equivalent to IConstructCurve.ConstructExtended
Example
// build a polyline
var polyline = PolylineBuilder.CreatePolyline(new[]
{
  MapPointBuilder.CreateMapPoint(1, 1, 10, 20),
  MapPointBuilder.CreateMapPoint(0, 0, 10, 20),
  MapPointBuilder.CreateMapPoint(1, -1, 10, 20)
});

// build the extender line
var extender = PolylineBuilder.CreatePolyline(new[]
{
  MapPointBuilder.CreateMapPoint(2, 2),
  MapPointBuilder.CreateMapPoint(2, -2),
});

// extend
var result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.KeepEndAttributes);
Polyline extendedLine = result as Polyline;
// result.Parts[0].Points[0] = 2, 2, 10, 20
// result.parts[0].Points[1] = 1, 1, 10, 20
// result.Parts[0].Points[2] = 0, 0, 10, 20
// result.Parts[0].Points[3] = 1, -1, 10, 20
// result.Parts[0].Points[4] = 2, -2, 10, 20

// change the flags
result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.NoEndAttributes);
extendedLine = result as Polyline;
// result.Parts[0].Points[0] = 2, 2, 0
// result.parts[0].Points[1] = 1, 1, 10, 20
// result.Parts[0].Points[2] = 0, 0, 10, 20
// result.Parts[0].Points[3] = 1, -1, 10, 20
// result.Parts[0].Points[4] = 2, -2, 0

// extend
result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.KeepEndAttributes | ExtendFlags.NoExtendAtTo);
extendedLine = result as Polyline;
// result.Parts[0].Points[0] = 2, 2, 10, 20
// result.parts[0].Points[1] = 1, 1, 10, 20
// result.Parts[0].Points[2] = 0, 0, 10, 20
// result.Parts[0].Points[3] = 1, -1, 10, 20

// extend with no intersection 

polyline = PolylineBuilder.CreatePolyline(new[]
{
  MapPointBuilder.CreateMapPoint(1, 1),
  MapPointBuilder.CreateMapPoint(3, 1)
});

extender = PolylineBuilder.CreatePolyline(new[]
{
  MapPointBuilder.CreateMapPoint(1, 4),
  MapPointBuilder.CreateMapPoint(3, 4)
});

result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.Default);
// result = null
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 7

See Also

Reference

GeometryEngine Class
GeometryEngine Members
ExtendFlags Enumeration