Cannot implicitly convert type 'string' to 'ESRI.ArcGIS.Carto.ILayer'

3096
0
11-15-2015 09:10 AM
sudarhanbana
New Contributor

Hi

I am getting error like "Cannot implicitly convert type 'string' to 'ESRI.ArcGIS.Carto.ILayer'" .

Please help me how to solve this error.

Please find my code below.

private void cmdon_Click(object sender, EventArgs e)

        {

            ILayer selectedlayer;

            selectedlayer = getlayername(cmblayers.SelectedItem.ToString());

            selectedlayer.Visible = false;

        }

        private void cmdoff_Click(object sender, EventArgs e)

        {

        }

        private string  getlayername(string slayername)

        {

           

          

             IDocument doc = m_application.Document;

            IMxDocument pmxdoc = doc as IMxDocument ;

           

            IMap pmap = pmxdoc.FocusMap;

           

             for (int i = 0; i < pmap.LayerCount; i++)

             {

                 ILayer player = pmap.Layer;

                 if (player.Name == slayername)

                     return slayername;

                    

                

                

             }

             return null;

    }

    }

0 Kudos
0 Replies