How to use GetRange() :

class Program
{
static void Main(string[] args)
{
ArrayList list = new ArrayList();
list.Add(“One”);
list.Add(“Six”);
list.Add(“Four”);

ArrayList range = list.GetRange(0,3);
foreach (string s in range)
{
Console.WriteLine(s);
Console.ReadLine();
}
}
}
Output : 
One
Six
Four

N.B : Let            list.GetRange(m,n);
Here ,        m = position of starting element of an array
n = how many number of element(s) want to show serially from m


Other outputs :

list.GetRange(0,1)
list.GetRange(0,2)
list.GetRange(0,3)
One
One
One
Six
Six
Four

.

list.GetRange(1,1)
list.GetRange(1,2)
Six
Six
Four

 

list.GetRange(2,1)
Four

Leave a Reply