ArcGIS Pro 2.8 API Reference Guide
ExportToWKB(WKBExportFlags,Geometry,Byte[]) Method
Example 

ArcGIS.Core.Geometry Namespace > GeometryEngine Class > ExportToWKB Method : ExportToWKB(WKBExportFlags,Geometry,Byte[]) Method
A combination of WKBExportFlags which determines how the geometry is exported.
The geometry to write to the buffer.
The buffer to which the geometry will be written. The buffer must be large enough to hold the OGC well-known binary version of the input geometry.
Writes an OGC well-known binary formatted version of the input geometry to the specified buffer.
Syntax
public int ExportToWKB( 
   WKBExportFlags exportFlags,
   Geometry geometry,
   ref byte[] buffer
)
Public Overloads Function ExportToWKB( _
   ByVal exportFlags As WKBExportFlags, _
   ByVal geometry As Geometry, _
   ByRef buffer() As Byte _
) As Integer

Parameters

exportFlags
A combination of WKBExportFlags which determines how the geometry is exported.
geometry
The geometry to write to the buffer.
buffer
The buffer to which the geometry will be written. The buffer must be large enough to hold the OGC well-known binary version of the input geometry.

Return Value

The exact number of bytes written to the buffer.
Exceptions
ExceptionDescription
Geometry is null or empty.
The method is not implemented for GeometryBag or Multipatch.
The method is not implemented for geometry with curves.
Remarks
Does not support curves. Also, note that if the geometry contains ID information, this property will not be preserved in the export operation. The WKB OGC standard does not contain the ID property.
Example
// create a polyline
List<Coordinate2D> coords = new List<Coordinate2D>
{
  new Coordinate2D(0, 0),
  new Coordinate2D(0, 1),
  new Coordinate2D(1, 1),
  new Coordinate2D(1, 0)
};

Polyline polyline = PolylineBuilder.CreatePolyline(coords, SpatialReferences.WGS84);

WKBExportFlags wkbExportFlags = WKBExportFlags.wkbExportDefaults;
WKBImportFlags wkbImportFlags = WKBImportFlags.wkbImportDefaults;

// export and import
byte[] buffer = GeometryEngine.Instance.ExportToWKB(wkbExportFlags, polyline);
Geometry geometry = GeometryEngine.Instance.ImportFromWKB(wkbImportFlags, buffer, SpatialReferences.WGS84);
Polyline importPolyline = geometry as Polyline;


// alternatively, determine the size for the buffer
int bufferSize = GeometryEngine.Instance.GetWKBSize(wkbExportFlags, polyline);
buffer = new byte[bufferSize];
// export
bufferSize = GeometryEngine.Instance.ExportToWKB(wkbExportFlags, polyline, ref buffer);
// import
importPolyline = GeometryEngine.Instance.ImportFromWKB(wkbImportFlags, buffer, SpatialReferences.WGS84) as Polyline;
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

GeometryEngine Class
GeometryEngine Members
Overload List