ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Editing.Attributes Namespace / Attribute Class / GetField Method
Example

In This Topic
    GetField Method (Attribute)
    In This Topic
    Gets the field of this attribute. Returns a field only if the data source is an Enterprise Geodatabase or File Geodatabase. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function GetField() As Field
    public Field GetField()

    Return Value

    Type: Field
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Get a layers schema using Inspector
    // Loads the schema of the specified feature layer and iterates through its attributes,  providing access to their properties such as field name, alias, type, and other metadata.
    await QueuedTask.Run(() =>
    {
      // create an instance of the inspector class
      var inspector = new Inspector();
      // load the layer
      inspector.LoadSchema(featureLayer);
      // iterate through the attributes, looking at properties
      foreach (var attribute in inspector)
      {
        var fldName = attribute.FieldName;
        var fldAlias = attribute.FieldAlias;
        var fldType = attribute.FieldType;
        int idxFld = attribute.FieldIndex;
        var fld = attribute.GetField();
        var isNullable = attribute.IsNullable;
        var isEditable = attribute.IsEditable;
        var isVisible = attribute.IsVisible;
        var isSystemField = attribute.IsSystemField;
        var isGeometryField = attribute.IsGeometryField;
      }
    });
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also