您的位置:首页 > 编程语言 > C#

C#“可访问性不一致”问题

2016-01-25 15:29 531 查看
可访问性不一致:
参数类型“parameter type”比方法“member method”的访问性低






返回类型和方法的形参表中引用的各个类型必须至少具有和方法本身相同的可访问性

可访问约束请参看:ms-help://MS.MSDNQTR.2003FEB.2052/csspec/html/vclrfcsharpspec_3_5_4.htm

using System;

class Class1

{

enum
EmployeeType{ Instructor, Sales, Officer };

public void ChooseEmployee(EmployeeType
c) //CS0051错误,方法的形参引用的类型EmployeeType,

//与方法本身ChooseEmployee的可访问性不一致

{

//....

}

}

//应该改为

using System;

class Class1

{

public enum
EmployeeType{ Instructor, Sales, Officer };

public void ChooseEmployee(EmployeeType
c) //访问性一致,都是public

{

//....

}

}

2

public
static Bestway.Tools.Protocol m_Protocol =
null;

class Protocol

{

public
Protocol()

{

}

}

错误 1可访问性不一致:
字段类型“Bestway.Tools.Protocol”比字段“Global.Params.m_Protocol”的可访问性低

修改如下,OK

public
static Bestway.Tools.Protocol m_Protocol =
null;

public
class Protocol

{

public
Protocol()

{

}

}

搜索

复制

复制去Google翻译翻译结果
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: