title: Working with in memory FeatureSet and Feature DotSpatial
body: <p>I'm a beginner with DotSpatial and I'm stuck with a problem.
  I try to work with in memory feature (to keep them only in Map) until the user hit save button.
  The basic idea is that the user imports some dxf files and creates featureset  based on layer name if the FeatureSet doesn't all ready exist, and for each polyline from dxf creates feature which will be added into a featureset.  </p>
  
  <pre><code> public IFeature AddPoligons(EntityObject polyline, List&lt;Text&gt; textInDxf)
  {
      IFeatureSet featureSet = null;
      //Getting the right featureset from map
      foreach (var x in appManager.Map.GetPolygonLayers())
      {
          if (!string.Equals(x.DataSet.Name, layerName)) continue;
  
          featureSet = x.DataSet as FeatureSet;
          break;
      }
      var polygon = CreatePolygon(polyline);
  
      //Creating feature and adding to FeatureSet
      var feature = featureSet.AddFeature(polygon);
  
      //Populating DataRow with information
      AddinfoIntoDataTable(feature, polygon, textInDxf);
      return feature;
  }
  </code></pre>
  
  <p>Everything thing looks fine, the map is updated with new polygons, can select them, view information from datatable BUT, when I try to delete a selected feature (polygon) it throws an IndexOutOfRange exception.</p>
  
  <p>What I'm doing wrong there? </p>
  
  <p>Please help! Thank you and sorry for my poor English.</p>
  
  <p>P.S.
  When I created the featureSet first I saved it on the disk and then loaded into map with Map.AddLayer() method.  </p>