名单(对T)和集(的T)之间的区别是什么? [英] What is the difference between List (of T) and Collection(of T)?

查看:126
本文介绍了名单(对T)和集(的T)之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过他们在很多相同的方式使用,我很担心我将要往下走的路径设计是不可逆的,如果我不明白这更好。另外,我使用.NET。

I've seen them used in a lot of the same ways, and I am worried I'm about to go down a path in design that is irreversible if I don't understand this better. Also, I am using .NET.

推荐答案

收藏< T> 可定制包装的IList< T> 。虽然的IList< T> 不是密封的,它不提供任何定制点。 收藏< T> 的方法都默认委托给标准的IList< T> 的方法,但可以很容易地重写做你想要什么。它也可以wireup内部事件收藏< T> ,我不相信能有一个IList来完成

Collection<T> is a customizable wrapper around IList<T>. While IList<T> is not sealed, it doesn't provide any customization points. Collection<T>'s methods are by default delegated to the standard IList<T> methods, but can be easily overridden to do what you want. It is also possible to wireup events inside a Collection<T> that I don't believe could be done with an IList.

在短,它更容易给它的事实,这可能意味着少了很多的重构后延伸。

In short, it's much easier to extend it after the fact, which could potentially mean a lot less refactoring.

这篇关于名单(对T)和集(的T)之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆