Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to retrieve all subtypes for a given feature class. ISubtypes.Subtypes give you an enumeration of all subtypes in the class. However the IEnumSubtype.Next method requires the subtype code to retrieve the associated subtype. But this obviously requires prior knowledge of all subtype codes. There are no methods on ISubtypes that retrieve all subtype codes. So, how do I obtain a list of both the subtype codes and subtype names associated with a feature class? I must be missing something obvious here.

share|improve this question
Notice that while the Next method requires the subtype code, it is prefaced byref, which means that you would provide a variable that gets set by the method. I think it would have made it clearer if Esri made it out instead of byref. – Kirk Kuykendall May 3 '12 at 19:54
Thank you, Kirk. That was it. I knew there was something I wasn't seeing. Much better than my workaround below. – Jeff Berry May 3 '12 at 20:26

I found a way to retrieve both the subtype codes and subtype names for a feature class using the Geoprocessor. I did not find a way to get the codes directly from ISubtypes, which I find unusual. In any case, the following code will create a Dictionary(Of Integer, String) containing the subtype code as the key and the subtype name as the value:

Dim gp as New Geoprocessor
Dim dtype As Object = ""
Dim dataElem As IDataElement = gp.GetDataElement("C:\Test.gdb\TestFC", dtype)
Dim deTbl As IDEGdbTable = TryCast(dataElem, IDEGdbTable)
Dim dictSubtypes as New Dictionary(Of Integer, String)
Dim arr as IArray = deTbl.Subtypes

For i As Integer = 0 To arr.Count - 1
    Dim gpSt as IGPSubtype = CType(arr.Element(i), IGPSubtype)
    dictSubtypes.Add(gpSt.SubtypeCode, gpSt.SubtypeName)
share|improve this answer

The C++ syntax for IEnumSubtype.Next shows that SubtypeCode is an out parameter. You can loop through IEnumSubtype getting both the subtype codes and descriptions for your featureclass. Loop while the returned string is not null.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.