当前位置: 移动技术网 > IT编程>开发语言>.net > 在编写Arcgis Engine 过程中对于接口引用和实现过程过产生的感悟

在编写Arcgis Engine 过程中对于接口引用和实现过程过产生的感悟

2019年03月29日  | 移动技术网IT编程  | 我要评论

毛晓舟,伦理mp4下载,苏秋妍

engine10.2版本

在vs里面新建类geomaoao,并定义接口,在class中定义并实现,如下代码

以平时练习为例,我定义了一个接口,在里面定义了许多的控件,并在类中想要实现这一接口。如果在vs软件中将引用都配置好一般情况下是不会报错的。

 1 //定义设置控件的接口
 2     interface icomcontrol
 3     {
 4         //主视图控件
 5         axmapcontrol axmapcontrol1 { get; set; }
 6         //鹰眼视图控件
 7         axmapcontrol axmapcontrol2 { get; set; }
 8         //版面视图控件
 9         axpagelayoutcontrol axpagelayoutcontrol1 { get; set; }
10         //定义设置颜色的方法
11         irgbcolor getrgb(int r, int g, int b);
12         //tooccontrol控件
13         axtoccontrol axtoccontrol1 { get; set; }
14     }
15     class geomapao : icomcontrol
16     {
17         axtoccontrol axtoccontrol1;
18         public axtoccontrol axtoccontrol1
19         {
20             get { return axtoccontrol1; }
21             set { axtoccontrol1 = value;}
22         }
23         //实现地图控件的接口
24         axmapcontrol axmapcontrol1;
25         public axmapcontrol axmapcontrol1
26         {
27             get { return axmapcontrol1; }
28             set { axmapcontrol1 = value;}
29         }
30         axmapcontrol axmapcontrol2;
31         public axmapcontrol axmapcontrol2
32         {
33             get { return axmapcontrol2; }
34             set { axmapcontrol2 = value; }
35         }
36         axpagelayoutcontrol axpagelayoutcontrol1;
37         public axpagelayoutcontrol axpagelayoutcontrol1
38         {
39             get { return axpagelayoutcontrol1; }
40             set { axpagelayoutcontrol1 = value; }
41         }
42         //定义实现获取rgb颜色的方法
43         public irgbcolor getrgb(int r, int g, int b)//方法名字叫getrgb方法,用的时候即可复制整段public
44         {
45             irgbcolor pcolor = new rgbcolorclass();
46             pcolor.red = r;
47             pcolor.green = g;
48             pcolor.blue = b;
49             return pcolor;
50         }
51         }

以上代码,是没有问题的,但如果对方法里面的定义做些小改动,如18行中的

”public axtoccontrol axtoccontrol1“改成”public axtoccontrol axtoccontrl1“,那我的系统在调试的时候就会报错

类的名字我起的是geomaoao,接口icomcontrol无法被实现,是因为方法定义的句子产生错误,无法被引用,就导致此错误。

今天因为代码写得不够细致,在观察时没有仔细的去看,粗心导致了很多类似的错误,引用老师的一句话“电脑是不会骗人的,能骗倒你的只有你自己。”引以为戒,分享出来作为第一条博客。


 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网