AnsweredAssumed Answered

First or Default

Question asked by bulla_b on Jun 12, 2018
Latest reply on Jun 13, 2018 by bulla_b

Hi,

 

When using the following code to find a specific layer in my map, I am finding that if a similarly named layer exists first in the TOC, then the FeatureLayer object gets set to it.

 

FeatureLayer sanForceMainLayer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Name.IndexOf("GISWRKS1.WORKS.ForceMain", StringComparison.CurrentCultureIgnoreCase) >= 0).FirstOrDefault();

 

For example, if I have a TOC like this:

 

layer1

layer2

GISWRKS1.WORKS.ForceMain_removals

layer4

layer5

GISWRKS1.WORKS.ForceMain

layer7

 

In this case, sanForceMainLayer is getting set to 'GISWRKS1.WORKS.ForceMain_removals'.  I am expecting it to match exactly to 'GISWRKS1.WORKS.ForceMain'.

 

Thanks,

Outcomes