静态类中不一致的可访问性错误
我在以下声明中遇到不一致的可访问性错误:
public static class Helper
{
public static void GetMyDictionary(Dictionary<string, string> dict)
{
dict = new Dictionary<string, string>();
// continue to do something
}
}
有人知道它的哪一部分导致了错误吗?
I'm getting inconsistent accessibility error in the following declaration:
public static class Helper
{
public static void GetMyDictionary(Dictionary<string, string> dict)
{
dict = new Dictionary<string, string>();
// continue to do something
}
}
Anyone know which part of it is causing the error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我要冒险说这段代码引用的
Dictionary
类实际上不是System.Collections.Generic.Dictionary
,而是其他一些项目中存在的字典
。如果此类的可访问性不是public
,编译器会抱怨您无法向世界公开方法GetMyDictionary
(如果其参数之一的类型无法访问)说世界。如果情况并非如此,则问题出在其他地方,而不是在您给出的代码中。
无论如何,发布准确的错误消息将有助于减少猜测。
I 'm going to go out on a limb here and say that the
Dictionary
class this code refers to is not in factSystem.Collections.Generic.Dictionary
, but some otherDictionary
that exists in your project. If the accessibility of this class is notpublic
, the compiler will complain that you cannot expose to the world the methodGetMyDictionary
if one of its parameters is of a type not accessible to said world.If this is not the case, then the problem is somewhere else and not in the code you give.
In any case, posting the exact error message would help reduce the guessing.