I am trying to remove a specific feature by its id/key in an InMemoryFeatureLayer by simply doing:
if (layer.InternalFeatures.Count > 0)
{
layer.InternalFeatures.Remove("sampleId");
}
However, the feature is not removed. I have verified the feature within the internal features also has an id of “sampleId”.
The feature is being added like:
layer.InternalFeatures.Add(feature.Id, feature); // feature.Id is "sampleId"
Why would the remove not work in this case?
If I get the index of the feature and do layer.InternalFeatures.RemoveAt(index)
it works.
layer.InternalFeatures.RemoveAll(feature => string.Equals(feature.Id, "sampleId", StringComparison.OrdinalIgnoreCase));
also works.
Using version 12.0 of your products.