How do I use a generic List?

378
1
Jump to solution
09-30-2013 05:08 AM
ReneeCammarere
Occasional Contributor
I've got the following routine . . .
      /// <summary>         /// Gets a list of all geoms in a Feature Class         /// </summary>         /// <param name="FClass">The Feature Class</param>         /// <returns>a List of Geometries</returns>         private List<T> GetGeometries<T>(IFeatureClass FClass)         {             List<T> List_Geometries = new List<T>();              IQueryFilter aQF = new QueryFilter();             aQF.WhereClause = "";             ISelectionSet selectionSet = FClass.Select(aQF, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, null);             IEnumIDs enumId = selectionSet.IDs;             int nFeatures = selectionSet.Count;             enumId.Reset();             int id;             for (int j = 0; j < nFeatures; j++)             {                 id = enumId.Next();                 IGeometry pGeom = FClass.GetFeature(id).Shape;                 List_Geometries.Add((T)pGeom);             }             return List_Geometries;         }


I don't get any diagnostics errors on the above routine.  However I do get an error when I attempt to call this method.  How can I call this method from the following set of code . . .
       private List<IPoint> GetPointsList(IFeatureRepository Bfr)
        {
            IFeatureClass Bfc = Bfr.GetFeatureClassByName("PointFeatureClass");
            List<IPoint> listPoints = GetGeometries(Bfc);
            return listPoints;
        }

By the way, this is not the way to do it, but I'm just trying to give an example of what I'm trying to do.

Thanks,
Renee
0 Kudos
1 Solution

Accepted Solutions
ReneeCammarere
Occasional Contributor
I was able to resolve this on my own.

   private List<IPoint> GetPointsList(IFeatureRepository Bfr)     {         IFeatureClass Bfc = Bfr.GetFeatureClassByName("PointFeatureClass");         List<IPoint> listPoints = GetGeometries<IPoint>(Bfc);         return listPoints;     }

View solution in original post

0 Kudos
1 Reply
ReneeCammarere
Occasional Contributor
I was able to resolve this on my own.

   private List<IPoint> GetPointsList(IFeatureRepository Bfr)     {         IFeatureClass Bfc = Bfr.GetFeatureClassByName("PointFeatureClass");         List<IPoint> listPoints = GetGeometries<IPoint>(Bfc);         return listPoints;     }
0 Kudos