ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data Namespace / Field Class / GetDomain Method
The specific Subtype for the field's domain. This argument is optional. If unset or set to null, the field's domain at the table level is returned.
Example

In This Topic
    GetDomain Method
    In This Topic
    Gets the field's Domain at the table level if subtype is not set. Otherwise, gets the field's domain for the specific subtype. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function GetDomain( _
       Optional ByVal subtype As Subtype _
    ) As Domain
    public Domain GetDomain( 
       Subtype subtype
    )

    Parameters

    subtype
    The specific Subtype for the field's domain. This argument is optional. If unset or set to null, the field's domain at the table level is returned.

    Return Value

    The associated domain if one is assigned; otherwise, null is returned.
    Exceptions
    ExceptionDescription
    A geodatabase-related exception has occurred.
    Example
    Get domain string from a field
    {
      // Must be called within QueuedTask.Run
      string GetDomainStringFromField(Row row, Field field)
      {
        // Get the table and table definition from the Row
        using (Table table = row.GetTable())
        using (TableDefinition tableDefinition = table.GetDefinition())
        {
          // Get name of subtype field
          string subtypeFieldName = tableDefinition.GetSubtypeField();
    
          // Get subtype, if any
          Subtype subtype = null;
    
          if (subtypeFieldName.Length != 0)
          {
            // Get value of subtype field for this row
            object varSubtypeCode = row[subtypeFieldName];
            long subtypeCode = (long)varSubtypeCode;
    
            // Get subtype for this row
            subtype = tableDefinition.GetSubtypes().First(x => x.GetCode() == subtypeCode);
          }
    
          // Get the coded value domain for this field
          CodedValueDomain domain = field.GetDomain(subtype) as CodedValueDomain;
    
          // Return the text string for this field
          if (domain != null)
          {
            return domain.GetName(row[field.Name]);
          }
    
          return row[field.Name].ToString();
        }
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also