【发布时间】:2011-08-07 19:55:18
【问题描述】:
我有一个界面
public interface ITcpSerializable<T>
{
Byte[] Serialize();
T Deserialize(Byte[] data);
}
在我的一个单独的类中,我希望公开以下属性。
public List<ITcpSerializable> RegisteredTypes { get; set; }
问题是我收到以下错误。
使用泛型类型 'ITcpSerializable' 需要 1 种类型 论据
现在我了解了错误以及如何纠正它,但问题是我不希望将我的 RegisteredTypes 属性限制为我的 ITcpSerializable 接口的特定类型化实现。
有没有办法解决这个问题?希望我要完成的工作很明确。
编辑:好的,我已经完全填满了我试图解释的内容。只是点击一下,我的想法完全歪曲了。请参阅这个问题了解我的实际问题:Constrain public property to specific types in List<Type>
【问题讨论】:
标签: c# generics interface types