IList<> IEnumerable<> ReadOnlyCollection<> 使用方向

无论你把它声明为IList<string>IEnumerable<string>ReadOnlyCollection<string>或别的东西,是你......如果你期望它应该只作为一个序列来处理,那么IEnumerable<string>很可能是最合适的。如果订单很重要并且您希望人们能够通过索引访问它,则IList<T>可能是合适的。如果你想使不变性显而易见,宣布它ReadOnlyCollection<T>可能很方便 - 但不灵活。

原文地址:https://www.cnblogs.com/z45281625/p/11091293.html