Yes,we know ArrayList is Collection which implements the interfaces IList for basic operations like Add,Remove,Removeat,Clear...ect and ICollection for Count and IEnumerable for iteration purposes.
but why Array Class implements these IList,ICollection,IEnumerable interfaces.why because Arrays(int,string...ect) also supports collections(Arraylist,sortleted...ect) funcationalities also.
Ex:
Array: IEnumerable
int[] arrint = { 10, 20, 30 };
IEnumerator ier = arrint.GetEnumerator();
while (ier.MoveNext())
{
int i = (int)ier.Current;
Console.WriteLine(i);
}
Console.ReadKey();
--------------------------arrays(int,string,...ect)supports iterations help of IEnumerable.
Ex:
Array :ICollection
but why Array Class implements these IList,ICollection,IEnumerable interfaces.why because Arrays(int,string...ect) also supports collections(Arraylist,sortleted...ect) funcationalities also.
Ex:
Array: IEnumerable
int[] arrint = { 10, 20, 30 };
IEnumerator ier = arrint.GetEnumerator();
while (ier.MoveNext())
{
int i = (int)ier.Current;
Console.WriteLine(i);
}
Console.ReadKey();
--------------------------arrays(int,string,...ect)supports iterations help of IEnumerable.
Ex:
Array :ICollection
No comments:
Post a Comment