I am trying to get a list of the fields in a feature inside the project default geodatabase.
what is the c# pro sdk equivalent of the python below?
for lyr in m.listLayers():
if lyr.name == "layer":
field_names = []
fields = arcpy.ListFields(lyr)
for field in fields:
field_names.append(field.name)
Do i have to go through the geodatabse API with a feature definition to get that list? like below. or is there a shorter or more prefered way?
using (Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath((uri))))
using (FeatureClass featureClass = fileGeodatabase.OpenDataset<FeatureClass>(matchLyr))
{
FeatureClassDefinition LyrDefinition = featureClass.GetDefinition();
IReadOnlyList<Field> fields = LyrDefinition.GetFields();
List<string> fieldList = new List<string>();
foreach (var fld in fields)
{
fieldList.Add(fld.Name);
Debug.WriteLine(fld.Name);
}
return fieldList;
}