No, if there is no functional need for it, don't add it.
There is some legacy in the framework classes due to historic reasons. But if you take a look at some newer interfaces like IReadOnlyCollection it only have a generic version. Older interfaces like IEnumerable predates the generic version.
There are some situations where a non generic base type is useful, like when you want to treat a bunch of objects with different generic parameters in the same way, but that is a rather specialized use case.
发布评论
评论(1)
不,如果没有功能需要,请不要添加。
由于历史原因,框架课上有一些遗产。但是,如果您查看一些较新的接口,例如 iReadonLyCollection 它只有一个通用版本。像iEnumerable这样的旧接口早于通用版本。
在某些情况下,非通用基本类型是有用的,例如,您想以相同的方式处理一堆具有不同通用参数的对象时,但这是一个相当专业的用例。
No, if there is no functional need for it, don't add it.
There is some legacy in the framework classes due to historic reasons. But if you take a look at some newer interfaces like IReadOnlyCollection it only have a generic version. Older interfaces like IEnumerable predates the generic version.
There are some situations where a non generic base type is useful, like when you want to treat a bunch of objects with different generic parameters in the same way, but that is a rather specialized use case.