摘要:集合練習 List , ArrayList , Array
//List練習 元素型別需要統一
List<int> sList = new List<int>();
sList.Add(30);
sList.Add(28);
sList.Add(31);
sList.Add(41);
sList.Sort();
sList.Reverse();
foreach (int i in sList)
{
//Response.Write(i + "<br>");
}
//ArrayList練習 元素型別可以不統一
ArrayList oTest = new ArrayList();
oTest.Add(13);
oTest.Add("NAME");
oTest.Add(20);
oTest.Add(18);
oTest.Add("allen");
oTest.Add("Zooooo");
foreach (object oObject in oTest)
{
//Response.Write(oObject. ToString()+"<br>");
}
//Array練習
int[] iScore = new int[5] { 55, 33, 11, 44, 22 };
Array.Sort(iScore);
foreach (int i in iScore)
{
Response.Write(i + "<br>");
}
PS:需要引入using system collections;