这类似于我最近发布的另一个主题,但也许这可能更简单明了:
我想完成以下(或非常相似的事情)......
IManageableEntryDao<IManageableEntry> dao = new CompanyNameDao();
...具有以下课程:
public interface IManageableEntry {
string Name { get; set; }
}
public class CompanyName : IManageableEntry {
public string Name { get; set; }
}
public interface IManageableEntryDao<T> where T : IManageableEntry {
}
public class CompanyNameDao : IManageableEntryDao<CompanyName> {
}
如果我尝试进行 cast as IManageableEntryDao<IManageableEntry>
,我会得到一个空值。