MSDN上描述:public interface IList : ICollection, IEnumerable
而其中继承的一个接口ICollection却是继承了IEnumerable
public interface ICollection : IEnumerable问题:
为什么不直接这样,还要加上IEnumerable?迷惑中……
public interface IList : ICollection
而其中继承的一个接口ICollection却是继承了IEnumerable
public interface ICollection : IEnumerable问题:
为什么不直接这样,还要加上IEnumerable?迷惑中……
public interface IList : ICollection
ICollection实现了IEnumerable中一部分方法 有一部分没有实现 直接以空方法替代
那么IList可以多实现一些方法 比如那些空方法
变的跟楼主一样困惑:(
人人认为啊,别B4
{
#region IList 成员 public int Add(object value)
{
throw new Exception("The method or operation is not implemented.");
} public void Clear()
{
throw new Exception("The method or operation is not implemented.");
} public bool Contains(object value)
{
throw new Exception("The method or operation is not implemented.");
} public int IndexOf(object value)
{
throw new Exception("The method or operation is not implemented.");
} public void Insert(int index, object value)
{
throw new Exception("The method or operation is not implemented.");
} public bool IsFixedSize
{
get { throw new Exception("The method or operation is not implemented."); }
} public bool IsReadOnly
{
get { throw new Exception("The method or operation is not implemented."); }
} public void Remove(object value)
{
throw new Exception("The method or operation is not implemented.");
} public void RemoveAt(int index)
{
throw new Exception("The method or operation is not implemented.");
} public object this[int index]
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
} #endregion #region ICollection 成员 public void CopyTo(Array array, int index)
{
throw new Exception("The method or operation is not implemented.");
} public int Count
{
get { throw new Exception("The method or operation is not implemented."); }
} public bool IsSynchronized
{
get { throw new Exception("The method or operation is not implemented."); }
} public object SyncRoot
{
get { throw new Exception("The method or operation is not implemented."); }
} #endregion #region IEnumerable 成员 public IEnumerator GetEnumerator()
{
throw new Exception("The method or operation is not implemented.");
} #endregion
}
这个是实现这两个接口的具体类