【问题标题】:Why do I get "inconsitent accesibilty:paramater type... is less accesable than method" error when all parameters are public? [duplicate]当所有参数都是公共的时,为什么会出现“不一致的可访问性:参数类型...比方法更难访问”错误? [复制]
【发布时间】:2020-12-14 19:04:03
【问题描述】:

我正在通过它的构造函数将我添加到新表单的对象列表传递给它,这就是显示错误的地方

public FindRoute(List<AddedLocation> AddedLocation)
    {

        ...
        
    }

这是它所基于的类

class AddedLocation
{
    public string name;
    public string PlaceID;

    public AddedLocation(string _name,string _PlaceID)
    {
        name = _name;
        PlaceID = _PlaceID;
    }
   
}

【问题讨论】:

    标签: c# wpf visual-studio


    【解决方案1】:

    将您的类声明从 class AddedLocation 更改为 public class AddedLocation。由于您尚未声明保护级别,因此它默认为internal,它比public 更难访问,这是您的构造函数所声明的。

    请看what-are-the-default-access-modifiers-in-c#

    【讨论】:

      猜你喜欢
      • 2011-09-07
      • 1970-01-01
      • 1970-01-01
      • 2019-01-12
      • 2014-10-31
      • 2021-07-12
      • 2014-07-25
      相关资源
      最近更新 更多