Yes, All Collections implements the one more collection is called IEnumerable. this IEnumerable has one method is called GetEnumerator()
again this GetEnumerator() return type is IEnumerator,IEnumerator has few methods which are helpful to
iterate through all the element in that collection.
Ex: In our framework many collections(ArrayList,SortedList,Hasttable..ect)..implements the
class ArrayList : IList, ICollection, IEnumerable, ICloneable
{
public virtual IEnumerator GetEnumerator(); // used to get the elements of the apporiate type
}
What is IEnumerable ?
IEnumerable is an interface which is to used define with few members which are used to iteration of same type of their apporiatecollections.
not only ArrayList.all collections(sortedlist,hasttable,...ect) we can iterate like this. way because all collections implements
this IEnumerator Interface.
as well as we can iterate through Array types also. way because these array class implements the IEnumerable interface.
the Array can be string,int, bool..any array we can iterator through IEnumerable manner.
Example:
this IEnumerator Interface.
as well as we can iterate through Array types also. way because these array class implements the IEnumerable interface.
the Array can be string,int, bool..any array we can iterator through IEnumerable manner.
Example:
so we can iterate through any type array it can be int,string,bool,float..ect
No comments:
Post a Comment