private void AddField(IFeatureClass pFeatureClass, string name, string aliasName, esriFieldType FieldType) { //若存在,则不需添加 if(pFeatureClass.Fields.FindField(name) > -1) return ; IField pField = new FieldClass(); IFieldEdit pFieldEdit = pField as IFieldEdit; pFieldEdit.AliasName_2 = aliasName; pFieldEdit.Name_2 = name; pFieldEdit.Type_2 = FieldType; IClass pClass = pFeatureClass as IClass; pClass.AddField(pField); }
在现有表中添加字段,需要用到 IField , IFieldEdit, IFeatureClass,
其中IFieldEdit主要是用于创建IField相关信息,包括name、type等;
IClass 则用于向表中插入新的字段 pClass.AddField(pField);
时间: 2024-10-24 10:45:41