ArcEngine获取指定字段的最大值
获取指定字段的最大值时,用到了ITableSort 首先对字段进行排序,然后获取取到的第一个pRow的值
int iIndex = FeatureClass.Fields.FindField(FieldName); FieldName为字段名,字段不存在时iIndex为-1
if(iIndex>0)
{
ITableSort pTableSort = new TableSortClass();
pTableSort.Table = (FeatureClass as ITable);
pTableSort.Fields = FieldName;
pTableSort.set_Ascending(FieldName, false);
pTableSort.Sort(null);
ICursor pCursor = pTableSort.Rows;
IRow pRow = pCursor.NextRow();
if (pRow != null)
{
string sValue = pRow.get_Value(iIndex).ToString();
int iMaxID = 0; 保存最大值
int.TryParse(sValue, out iMaxID);
}
}