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

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)
  //lstQuerValue is the listbox

  //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.

share|improve this question
duplicated or replaced with a new reference? – steffan Jan 15 '13 at 18:31
yes replaced with a new reference – Jagadesh Jan 15 '13 at 18:34
up vote 4 down vote accepted

If what's happening is that all the items in PFeatureList are the same, then try using a non-recycling cursor.

pFeatureCursor = pFeatureClass.Search(pQueryFilter, false);
share|improve this answer
Thank you problem solved but what actually happening when i replaced true with false plz.. – Jagadesh Jan 15 '13 at 18:39
This determines what type of cursor your search method is returning. Read the API reference for IFeatureClass.Search and also look at… under the section Understanding Recycling – kenbuja Jan 15 '13 at 18:52

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.