public interface IEnumeratorpublic interface ICollection : IEnumeratorpublic interface IList : ICollectionpubilc class ArrayList : IList,ICollection,IEnumerator为何不是public class ArrayList : IList
IList接口不是已经继承了上面的两个接口了吗?
而且这样为何不会出现接口重定义,IList已经包含了ICollection中的接口了.

解决方案 »

  1.   

    为何不是public class ArrayList : IList 为何要用public interface IList : ICollection 
     
    那样还不如不要把IList继承ICollection有点不理解
      

  2.   


    public interface IEnumerator
    {
        object Current { get; };
        bool MoveNext ();
        void Reset ();
    }public interface ICollection : IEnumerator //ICollection并没有实现IEnumerator中的成员
    {
        int Count { get; };
        bool IsSynchronized { get; };
        object SyncRoot { get; };
        void CopyTo (Array array,int index);
    }public interface IList : ICollection, IEnumerable //IList并没有实现ICollection和IEnerable中的成员
    {
        bool IsFixedSize { get; };
        bool IsReadOnly { get; };
        object this [int index] { get; set; };
        int Add (object value);
        void Clear ();
        bool Contains (Object value);
        int IndexOf (Object value);
        void Insert (int index,Object value);
        void Remove (Object value);
        void RemoveAt (int index);
    }
      

  3.   

    http://msdn.microsoft.com/zh-cn/library/ms173157.aspx
      

  4.   

    恩,主要是想问ICollection继承了IEnumerator
    那么IList只需继承ICollection便可,为何又要继承IEnumerator
    希望能解决下
      

  5.   

    大家可以参看一下:http://topic.csdn.net/t/20060207/20/4544157.html
    这一贴,pubilc class ArrayList : IList,ICollection,IEnumerator 
    其实完全可以使用public class ArrayList : IList来替代.
    因为IList本身已经继承了ICollection而ICollection又继承了IEnumerator.所以传递性.pubilc class ArrayList : IList,ICollection,IEnumerator 
    这种定义方法有两种好处:
    一,象上面一个朋友说的,提高代码可读性,
    二,也是比较重要的,可以显示的实现接口.

    public class ArrayList : IList,ICollection,IEnumerator
    {
        IList.xxx(){}
        ICollection.xxxxx(){}
        IEnumerator.xxxxxxx(){}
    }有点儿明白,呆会再结贴,相信有很多人像我一样犯迷糊.
      

  6.   

    public class ArrayList : IList这样也是可以显示实现接口的
      

  7.   

    public class ArrayList : IList 这样也是可以显示实现接口的恩,是可以显示实现接口,
    如果是IList.GetEnumerator() 那样的话代码并不是很友好..