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 <SPAN class="operator token">=</SPAN> map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetLayersAsFlattenedList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>OfType<SPAN class="operator token"><</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Where</SPAN><SPAN class="punctuation token">(</SPAN>l <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> l<SPAN class="punctuation token">.</SPAN>Name<SPAN class="punctuation token">.</SPAN><SPAN class="token function">IndexOf</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"GISWRKS1.WORKS.ForceMain"</SPAN><SPAN class="punctuation token">,</SPAN> StringComparison<SPAN class="punctuation token">.</SPAN>CurrentCultureIgnoreCase<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">>=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
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,