查看接口System.Collections.Generic.ICollection,它的定义要求继承成员包含属性bool IsReadOnly { get;}。
但是,我接着看了类System.Collections.Generic.List,它继承了System.Collections.Generic.ICollection,这个类不包含bool IsReadOnly { get;}的定义。遗传链是怎么断的,还是我漏掉了什么?
发布于 2010-08-19 06:20:11
发布于 2010-08-19 06:17:05
发布于 2010-08-19 06:19:24
它位于IList部分:
IList实现ICollection
public class List<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable
{
public List();
public List(int capacity);
public List(IEnumerable<T> collection);
public int Capacity { get; set; }
#region IList Members
int IList.Add(object item);
bool IList.Contains(object item);
void ICollection.CopyTo(Array array, int arrayIndex);
int IList.IndexOf(object item);
void IList.Insert(int index, object item);
void IList.Remove(object item);
bool IList.IsFixedSize { get; }
bool IList.IsReadOnly { get; }
bool ICollection.IsSynchronized { get; }
object ICollection.SyncRoot { get; }
object IList.this[int index] { get; set; }
#endregion
...and so on
}https://stackoverflow.com/questions/3519184
复制相似问题