1 /// <summary>
2
///
得到要素类某字段的唯一值
3 /// </summary>
4 /// <param name="pFeatureClass"> 要素类 </param>
5 /// <param name="strFld"> 指定要得到唯一值的字段 </param>
6 /// <returns> 唯一值字符数据 </returns>
7 List< string> GetUniqueValue(IFeatureClass pFeatureClass, string strFld)
8 {
9 List< string> lst = new List< string>();
10 // 得到IFeatureCursor游标
11 IFeatureCursor pCursor = pFeatureClass.Search( null, false);
12
13 // coClass对象实例生成
14 IDataStatistics pData = new DataStatisticsClass();
15 pData.Field = strFld;
16 pData.Cursor = pCursor as ICursor;
17
18 // 枚举唯一值
19 IEnumerator pEnumVar = pData.UniqueValues;
20
21 // 记录总数
22 int RecordCount = pData.UniqueValueCount;
23
24 // 字符数组
25 pEnumVar.Reset();
26
27 while (pEnumVar.MoveNext())
28 {
29 lst.Add(pEnumVar.Current.ToString());
30 }
31
32 return lst;
33 }
3 /// </summary>
4 /// <param name="pFeatureClass"> 要素类 </param>
5 /// <param name="strFld"> 指定要得到唯一值的字段 </param>
6 /// <returns> 唯一值字符数据 </returns>
7 List< string> GetUniqueValue(IFeatureClass pFeatureClass, string strFld)
8 {
9 List< string> lst = new List< string>();
10 // 得到IFeatureCursor游标
11 IFeatureCursor pCursor = pFeatureClass.Search( null, false);
12
13 // coClass对象实例生成
14 IDataStatistics pData = new DataStatisticsClass();
15 pData.Field = strFld;
16 pData.Cursor = pCursor as ICursor;
17
18 // 枚举唯一值
19 IEnumerator pEnumVar = pData.UniqueValues;
20
21 // 记录总数
22 int RecordCount = pData.UniqueValueCount;
23
24 // 字符数组
25 pEnumVar.Reset();
26
27 while (pEnumVar.MoveNext())
28 {
29 lst.Add(pEnumVar.Current.ToString());
30 }
31
32 return lst;
33 }
本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/p/4302784.html,如需转载请自行联系原作者