ArcObjects Library Reference (Geometry)  

IRelationalOperator.Contains Method

Indicates if this geometry contains the other geometry.

[Visual Basic .NET]
Public Function Contains ( _
    ByVal other As IGeometry _
) As Boolean
[C#]
public bool Contains (
    IGeometry other
);
[C++]
HRESULT Contains(
  IGeometry* other,
  VARIANT_BOOL* Contains
);
[C++]

Parameters

other

  other is a parameter of type IGeometry

Contains [out, retval]   Contains is a parameter of type VARIANT_BOOL

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

The base geometry contains the comparison geometry (other) if the comparison geometry is a subset of the base geometry and the intersection of their interiors is not empty. Therefore a polygon does not contain any part of its 1D boundary. Contains is the opposite operator of Within.

Remarks

Only geometries that support the IRelationalOperator interface can be used as input geometries.

If geometry1 Contains geometry2, then geometry2 is Within geometry1.

An empty geometry does not contain another geometry.  On the other hand, an empty geometry is contained in another geometry, unless the other geometry is empty.

Contains examples. Only "true" relationships are showed in this picture.

See Also

IRelationalOperator Interface

.NET Samples

Geoevents in a MapControl (Code Files: GeoEvents)