我正在为一个示例项目开发界面,我希望它尽可能地通用,因此我创建了以下接口:
public interface IUserFactory
{
IEnumerable<Users> GetAll();
Users GetOne(int Id);
}
但是接下来发生了这样的情况,我不得不复制该界面以完成下面的操作。
public interface IProjectFactory
{
IEnumerable<Projects> GetAll(User user);
Project GetOne(int Id);
}
如果您看上面的区别,它们只是返回类型不同,所以我创建了以下类似的内容,但却发现出现了错误Cannot Resolve Symbol T
我做错了什么
public interface IFactory
{
IEnumerable<T> GetAll();
T GetOne(int Id);
}
public interface IFactory
{
IEnumerable GetAll();
Type GetOne(int Id);
}
- DeeptechtonsType
是一个实际的.NET类名,所以这可能会产生歧义。但是泛型类型参数的名称可以是任何东西。 - Oded