using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace Arraylist
{
class Program
{
static void Main(string[] args)
{
ArrayList al = new ArrayList();
//向集合中添加元素
al.Add(3000);
al.Add(4000);
al.Add(5000);
al.Add(5000);
al.Add(5000);
数组的个数
//Console.WriteLine(al.Count);
数组的容量
//Console.WriteLine(al.Capacity);
//int a = Convert.ToInt32(al[0]);
//Console.WriteLine(a.ToString());
//遍历数组
//计算总工资 for循环
//int sum = 0;
//for (int i = 0; i < al.Count; i++)
//{
// int n = Convert.ToInt32(al[i]);
// sum += n;
//}
//Console.WriteLine(sum);
//foreach循环
int sum = 0;
foreach (object item in al)
{
int n = Convert.ToInt32(item);
sum += n;
}
Console.WriteLine(sum);
Console.Read();
}
}
}