【发布时间】:2021-01-16 22:51:21
【问题描述】:
我有一个公共接口:
public interface IDataService
{
Task<List<Data>> GetAll(string type);
}
还有一个实现它的DataService类:
public class DataService : IDataService
{
public async Task<List<Data>> GetAll(string type)
{
}
}
现在我得到了错误:
Inconsistent accessibility: return type 'Task<List<Data>>' is less accessible than method 'DataService.GetAll(string)'
这个实现有什么问题?恕我直言,一切都是公开的。
【问题讨论】:
-
Data公开吗? -
你确定
Data是公开的。也许它的公共嵌套在一个私有类中,或者私有嵌套在一个公共类中(注意如果省略,默认是私有的) -
只公开数据类型