ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / FieldDescription Class / CreateIntegerField Method
The name of the ArcGIS.Core.Data.Field to create.
Example

In This Topic
    CreateIntegerField Method
    In This Topic
    Creates a field description for an integer ArcGIS.Core.Data.Field.
    Syntax
    Public Shared Function CreateIntegerField( _
       ByVal name As String _
    ) As FieldDescription
    public static FieldDescription CreateIntegerField( 
       string name
    )

    Parameters

    name
    The name of the ArcGIS.Core.Data.Field to create.

    Return Value

    A field description for an integer ArcGIS.Core.Data.Field.
    Example
    Creating a feature class
    {
      // Must be called within QueuedTask.Run
      void CreateFeatureClassSnippet(Geodatabase geodatabase, FeatureClass existingFeatureClass,
        SpatialReference spatialReference)
      {
        // Create a Cities feature class with the following fields
        // GlobalID
        // ObjectID
        // Name (string)
        // Population (integer)
    
        // This helper routine creates a FieldDescription for a GlobalID field with default values
        FieldDescription globalIDFieldDescription = FieldDescription.CreateGlobalIDField();
    
        // This helper routine creates a FieldDescription for an ObjectID field with default values
        FieldDescription objectIDFieldDescription = FieldDescription.CreateObjectIDField();
    
        // This helper routine creates a FieldDescription for a string field
        FieldDescription nameFieldDescription = FieldDescription.CreateStringField("Name", 255);
    
        // This helper routine creates a FieldDescription for an integer field
        FieldDescription populationFieldDescription = FieldDescription.CreateIntegerField("Population");
    
        // Assemble a list of all of our field descriptions
        List<FieldDescription> fieldDescriptions = new List<FieldDescription>()
            { globalIDFieldDescription, objectIDFieldDescription, nameFieldDescription, populationFieldDescription };
    
        // Create a ShapeDescription object
        ShapeDescription shapeDescription = new ShapeDescription(GeometryType.Point, spatialReference);
    
        // Alternatively, ShapeDescriptions can be created from another feature class.  In this case, the new feature class will inherit the same shape properties of the existing class
        ShapeDescription alternativeShapeDescription = new ShapeDescription(existingFeatureClass.GetDefinition());
    
        // Enable support for measure (M) value, if needed
        // shapeDescription.HasM = true;
    
        // Enable support for the vertical coordinate system (Z), if needed
        // shapeDescription.HasZ = true;
    
        // Create a FeatureClassDescription object to describe the feature class to create
        FeatureClassDescription featureClassDescription =
          new FeatureClassDescription("Cities", fieldDescriptions, shapeDescription);
    
        // Create a SchemaBuilder object
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Add the creation of the Cities feature class to our list of DDL tasks
        schemaBuilder.Create(featureClassDescription);
    
        // Execute the DDL
        bool success = schemaBuilder.Build();
    
        // Inspect error messages
        if (!success)
        {
          IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages;
          //etc.
        }
      }
    }
    Adding fields to a FeatureClass
    {
      // Must be called within QueuedTask.Run
      void AddFieldsInFeatureClassSnippet(Geodatabase geodatabase)
      {
        // Adding following fields to the 'Parcels' FeatureClass
        // Global ID
        // Parcel_ID
        // Tax_Code
        // Parcel_Address
    
        // The FeatureClass to add fields
        string featureClassName = "Parcels";
    
        FeatureClassDefinition originalFeatureClassDefinition = geodatabase.GetDefinition<FeatureClassDefinition>(featureClassName);
        FeatureClassDescription originalFeatureClassDescription = new FeatureClassDescription(originalFeatureClassDefinition);
    
        // The four new fields to add on the 'Parcels' FeatureClass
        FieldDescription globalIdField = FieldDescription.CreateGlobalIDField();
        FieldDescription parcelIdDescription = new FieldDescription("Parcel_ID", FieldType.GUID);
        FieldDescription taxCodeDescription = FieldDescription.CreateIntegerField("Tax_Code");
        FieldDescription addressDescription = FieldDescription.CreateStringField("Parcel_Address", 150);
    
        List<FieldDescription> fieldsToAdd = new List<FieldDescription>
          {
            globalIdField, parcelIdDescription,
            taxCodeDescription, addressDescription
          };
    
        // Add new fields on the new FieldDescription list
        List<FieldDescription> modifiedFieldDescriptions = new List<FieldDescription>(originalFeatureClassDescription.FieldDescriptions);
        modifiedFieldDescriptions.AddRange(fieldsToAdd);
    
        // The new FeatureClassDescription with additional fields
        FeatureClassDescription modifiedFeatureClassDescription = new FeatureClassDescription(originalFeatureClassDescription.Name,
          modifiedFieldDescriptions, originalFeatureClassDescription.ShapeDescription);
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Update the 'Parcels' FeatureClass with newly added fields
        schemaBuilder.Modify(modifiedFeatureClassDescription);
        bool modifyStatus = schemaBuilder.Build();
    
        if (!modifyStatus)
        {
          IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
        }
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also