lArrays
l
Øint[] Array=new int[10000000]; int i;
long sum; sum=0;
Øfor (i=0;i<10000000;i++)
Array[i]=i+1;
Øfor (i=0;i<10000000;i++)
sum=sum+Array[i];
ØMessageBox.Show("Sum(array[i]=i)
from 1 to 1,000,000 = "+
Ø sum.ToString(),"Array",MessageBoxButtons.OK,
Ø MessageBoxIcon.Information);
Ø
lArrayLists
l
ØArrayList List=new
ArrayList(100000);
Øint i; long sum=0;
Øfor
(i=0;i<int.Parse(this.textBox2.Text);i++) List.Add(i+1);
ØMessageBox.Show("Created array
list","Created Array List",
Ø MessageBoxButtons.OK, MessageBoxIcon.Information);
Øfor (i=0;i<List.Count;i++)
sum=sum+(int)List[i];
ØMessageBox.Show("Sum(ArrayList)
from 1 to "+
Ø List.Count.ToString()+" =
"+sum.ToString(),"Summed Array List",
Ø MessageBoxButtons.OK, MessageBoxIcon.Information);
Ø