I am attempting to learn ArcObjects using a tutorial that uses VB.NET and I am trying to convert it to C#. I have Visual C# 2008 Express Edition. This is an ArcMap Add-In project that creates a button that displays a message box with the name of the top most layer in the data frame. Here is the VB.NET code:
Dim pMxDoc As IMxDocument pMxDoc = My.ArcMap.Application.Document Dim pMap As IMap pMap = pMxDoc.FocusMap Dim pFLayer As IFeatureLayer2 pFLayer = pMap.Layer(0) Dim strDisplayField As String strDisplayField = pFLayer.DisplayField MsgBox(strDisplayField, vbOKOnly, "Test")
My conversion in C# so far:
using ESRI.ArcGIS.ArcMapUI: using ESRI.ArcGIS.Carto; IMxDocument pMxDoc = ArcMap.Application.Document as IMxDocument; IMap pMap = pMxDoc.FocusMap; IFeatureLayer2 pFLayer = pMap.
There is no 'Layer' property. Only 'LayerCount' to choose from. I even tried this:
IFeatureLayer2 pFLayer = ArcMap.Application.Document as IFeatureLayer2; pFLayer = pMap.
this didn't work either. I have looked all over the ArcMap Object Diagram and I can't find the FeatureLayer2 class anywhere. According to ArcObjects SDK for .NET there is a Layer member for the IMap interface, but I don't have access to that. Any help would be grealty appreciated.