Based on the query i am getting some features in pFeatureCursor. I am adding that features into a List(IFeature). When iam iterating the pFeatureCursor and adding the values into pFeatureList all values in the list are replacing with the new reference pFeature
Please refer my code below
//List is declared globally
List<IFeature> pFeatureList = new List<IFeature>();
//In a method i am trying to add features in a list
//based on queryfilter
pFeatureCursor = pFeatureClass.Search(pQueryFilter, true);
IFeature pFeature = pFeatureCursor.NextFeature();
while (pFeature != null)
{
pFeatureList.Add(pFeature);
//lstQuerValue is the listbox
lstQueryValue.Items.Add(pFeature.get_Value(1).ToString());
//When below line is execute whatever the recent pFeature
//value is replacing all the items and duplicating in pFeatureList
pFeature = pFeatureCursor.NextFeature();
}
Please give some idea how to avoid it.