Select to view content in your preferred language

'ESRI.ArcGIS.Carto.IMap.Layer' cannot be used like a method

2812
3
Jump to solution
05-22-2012 08:31 AM
ShaningYu
Honored Contributor
I user to program ArcObjects using VB and then .Net. For such a simple piece of code (I used it before) as below:
IMxDocument pDoc = m_app.Document as IMxDocument;
IMap pMap = pDoc.FocusMap;
ILayer pLayer;
for (int i = 0; i < pMap.LayerCount; i++) {
pLayer = pMap.Layer(i); // Got error
//
}
Error 2 Non-invocable member 'ESRI.ArcGIS.Carto.IMap.Layer' cannot be used like a method.
What's wrong with it? Thanks.
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
Since you're working in C#, try

pLayer = pMap.get_Layer(i);

View solution in original post

0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor
Since you're working in C#, try

pLayer = pMap.get_Layer(i);
0 Kudos
ShaningYu
Honored Contributor
Got it.  Thanks.
0 Kudos
KenBuja
MVP Esteemed Contributor
Great. Don't forget to mark the question as answered.
0 Kudos