public 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;
}
}