标题:VS里Add-in开发错误提示GetLayerByName(string lyrName)不是所有的代码都有 ...
取消只看楼主
吴兴会
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-6-5
结帖率:0
已结贴  问题点数:20 回复次数:0 
VS里Add-in开发错误提示GetLayerByName(string lyrName)不是所有的代码都有的代码路径都有返回值怎么改呢?求各位大神帮忙
namespace GIStools
{
    public class search : ESRI.ArcGIS.Desktop.AddIns.Tool
    {

        private IApplication m_application;
        private static IMap map;
 
        public search()
        {
        }

        protected override void OnUpdate()
        {
             Enabled = ArcMap.Application != null;
        }
         public static ILayer GetLayerByName(string lyrName)
        {
             ILayer findLayer = null;
            IEnumLayer pEnumLayer = map.get_Layers();
             pEnumLayer.Reset();
             ILayer pLayer = pEnumLayer.Next();
             while (pLayer != null)
            {
                 if (pLayer.Name == lyrName)
                 {
                     findLayer = pLayer;
                }
               pLayer = pEnumLayer.Next();
                    return findLayer;
       }
            
        }
    }
}
搜索更多相关主题的帖子: private search public null 开发 
2017-06-05 11:07



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-477658-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.160072 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved