【发布时间】:2018-11-24 06:33:38
【问题描述】:
我有 3 个类具有几乎相同的字段:
public DateTime Date { get; set; }
public long? Value { get; set; }
public (Enum1 or Enum2 or Enum3) Type { get; set; }
所以我想为他们创建一些界面。但我不知道如何添加Type 字段。
也许不可能,因为枚举是值类型,只能从 System.Enum 派生,但也许有一些解决方案。
【问题讨论】:
-
IMyInterface<T> { T Type {get;set;} }不行吗?您可以像Class1 : IMyInterface<Enum1>一样使用它
标签: c# .net inheritance enums interface