Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • IEnumerable, ICollection and IList Interfaces

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 205
    Comment on it

    IEnumerable is the core of the ICollection and IList interfaces.

     

    IEnumerable Interface:

    IEnumerable interface is used to iterate values. Usually, it is used with the help of a foreach loop. It has only one method i.e. GetEnumerator(). It implements two methods MoveNext() and Reset() and has one property i.e. Current which returns the current element in the list. This is read-only access to collections. Any item changes inside an IEnumerable List are not allowed. Generally, it is used where we do not want to change the list.

     

    ICollection Interface:

    The ICollection interface is derived from base IEnumerable interface that is any class can also be enumerated using a foreach loop which implements the ICollection interface. The ICollection interface contains more properties than IEnumerable Interface  i.e. Count(total count of elements inside the list), IsSynchronized(thread-safe collection) and SyncRoot(thread-safe collection) properties. It contains CopyTo() Method that copies the entire collection into an array.

     

    IList Interface:

    The IList interface is derived from both ICollection and IEnumerable interfaces. It allows add and remove items from the collection. It also supports for accessing the items from the index. The IList interface contains IsFixedSize and IsReadOnly properies. It has Add(), Clear(), Contains(), Indexof(), Insert(), Remove() and RemoveAt() methods.  

    IList interface is more powerful than the ICollection and IEnumerable interface s.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: