Heim  >  Artikel  >  Datenbank  >  Inconsistent accessibility Error

Inconsistent accessibility Error

WBOY
WBOYOriginal
2016-06-07 15:38:021209Durchsuche

今天给Outlook做了一个根据邮件的Subjects移动邮件到指定文件夹的小东西。 刚开始使用C#,对于很多东西也是现用现学,再写自己的Outlook类的时候直接使用了VS自动生成的一些代码(类声明),结果编译的时候除了问题: Error1Inconsistent accessibility: pro

今天给Outlook做了一个根据邮件的Subjects移动邮件到指定文件夹的小东西。

刚开始使用C#,对于很多东西也是现用现学,再写自己的Outlook类的时候直接使用了VS自动生成的一些代码(类声明),结果编译的时候除了问题:

 

 

 

Error 1 Inconsistent accessibility: property type 'MoveMailBasedOnName.Outlook' is less accessible than property 'MoveMailBasedOnName.SettingForm.MyOutlook' 

 

这里面Outlook 类没有修改访问级别,使用的事默认访问。而在SettingForm中用于要在MainForm中访问SettingForm中的myOutlook属性,就设置了

 

privrate Outlook myOutlook = null;

 

public Outlook MyOutllok

{

    get{ return myOutlook; }

}

 

这也就是导致编译出错的罪魁祸首,因为Outlook类的默认访问级别为protect,所以低于设置get property时的public。所以出错。

所以修改方法也很简单,只需要将Outlook类的访问级别设置为public就可以了。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn