/// <summary> /// 得到要素类某字段的唯一值 /// </summary> /// <param name="pFeatureClass">要素类</param> /// <param name="strFld">指定要得到唯一值的字段</param> /// <returns>唯一值字符数据</returns> public static string[] GetUniqueValue(IFeatureClass pFeatureClass, string strFld) { //得到IFeatureCursor游标 IFeatureCursor pCursor = pFeatureClass.Search(null, false); //coClass对象实例生成 IDataStatistics pData = new DataStatisticsClass(); pData.Field = strFld; pData.Cursor = pCursor as ICursor; //枚举唯一值 IEnumerator pEnumVar = pData.UniqueValues; //记录总数 int RecordCount = pData.UniqueValueCount; //字符数组 string[] strValue = new string[RecordCount]; pEnumVar.Reset(); int i = 0; while (pEnumVar.MoveNext()) { strValue[++i] = pEnumVar.Current.ToString(); } return strValue; }