ArcObjects Library Reference  (GeoDatabase)    

IFeatureClass.GetFeature Method

Get the feature with the specified object ID.

[Visual Basic 6.0]
Function GetFeature(
    ByVal ID As Long _
) As IFeature
[Visual Basic .NET]
Public Function GetFeature ( _
    ByVal ID As Integer _
) As IFeature
[C#]
public IFeature GetFeature (
    int ID
);
[Java]
public IFeature getFeature (
    int ID
)
throws
    IOException,
    AutomationException
[C++]
HRESULT GetFeature(
  long ID,
  IFeature** Feature
);
[C++]

Parameters

ID [in]

  ID is a parameter of type long

Feature [out, retval]

  Feature is a parameter of type IFeature

Product Availability

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

Remarks

GetFeature will return the IFeature interface for a feature in the feature class with a given Object ID (OID). This method is typically used to find a particular feature that you know the OID for.  Use a cursor if you wish to loop through all features in the feature class.

Calling the GetFeature method on a feature class (via the IFeatureClass interface on the feature class) has the same effect as calling the GetRow method on the FeatureClass (via the ITable interface on the feature class) except that the IFeatureClass methods return IFeature interfaces.
 

[C#]     //e.g, nameOfField = "City_Name"
    public void IFeatureClass__GetFeature(IFeatureClass featureClass, string nameOfField)
    {
        //get the index of the field we are interested in
        int fieldIndexValue = featureClass.FindField(nameOfField);
        //Get feature with OID 11, because it is known to exist
        //This method is typically used to get a feature by know OID
        //If you wish to loop through a series of features, use a Cursor.
        IFeature feature = featureClass.GetFeature(1);
        Console.WriteLine("The {0} field contains a value of {1}", nameOfField, feature.get_Value(fieldIndexValue));
    }

See Also

IFeatureClass Interface | IFeature Interface | IFeatureCursor Interface

Example

IFeatureClass Example

 


Feedback Send feedback on this page