C# 接口和泛型#

C# 接口和泛型#,c#,generics,interface,C#,Generics,Interface,我有这样一个界面: public interface IMyInterface<T> where T:class { long OS { get; set; } T App { get; set; } } public interface IMyInterfaces { List<IMyInterface<T>> Subscribers { get; set; } //this li

我有这样一个界面:

public interface IMyInterface<T> where T:class
    {

        long OS { get; set; }

        T App { get; set; }
    }
public interface IMyInterfaces
    {
        List<IMyInterface<T>> Subscribers { get; set; } //this line give me error
    }
公共接口imy接口,其中T:class
{
长操作系统{get;set;}
T App{get;set;}
}
还有另一个像这样的界面:

public interface IMyInterface<T> where T:class
    {

        long OS { get; set; }

        T App { get; set; }
    }
public interface IMyInterfaces
    {
        List<IMyInterface<T>> Subscribers { get; set; } //this line give me error
    }
公共接口IMyInterfaces
{
列出订阅服务器{get;set;}//此行给我错误信息
}

出现错误

使用
IMyInterface
时,您需要为
T
指定一个具体类型或另一个通用参数

公共接口IMyInterfaces
{
列出订阅服务器{get;set;}
}

公共接口IMyInterfaces
{
列出订阅服务器{get;set;}
}

注意我使用了
TOther
来强调它是另一个通用参数,不同于
IMyInterface
中的
T
,但可以使用相同的名称(
T
)对于
TOther

当您使用
IMyInterface
时,您需要为
T
指定一个具体类型或另一个通用参数

公共接口IMyInterfaces
{
列出订阅服务器{get;set;}
}

公共接口IMyInterfaces
{
列出订阅服务器{get;set;}
}

注意我使用了
TOther
来强调它是另一个通用参数,不同于
IMyInterface
中的
T
,但是你可以使用相同的名称(
T
)来表示
TOther

注意,我想要一个列表,列出你也需要在IMyInterface中定义T的任何类型的tys,如果我定义T,我失去了可以存储任何类型的IMyInterface的列表注意,我想要一个任何类型的T的列表你也需要在IMyInterface中定义T如果我定义T,我失去了可以存储任何类型的IMyInterface的列表你的意思是没有办法,我有一个接口列表,接口可以是任何类型?你可以使用
IMyInterface
,任何东西都可以强制转换为对象。然后,不可以,您可以将
IMyInterfaces
设置为泛型,或者为
IMyInterface
指定一个具体的泛型参数。没有办法用一个免费的泛型类型参数来声明某个东西你的意思是没有办法,我有一个接口列表,接口可以是任何类型?你可以使用
IMyInterface
,任何东西都可以强制转换为对象。然后没有,您可以将
IMyInterfaces
设置为泛型,也可以为
IMyInterface
指定具体的泛型参数。无法使用自由泛型类型参数声明某些内容