Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Collections;
public partial class _default:system.web.ui.page
{
protected void Page_Load (object sender, EventArgs e)
{
System.Int32 is the structure
int[] arr = new int[] {1, 2, 3};
Response.Write (Arr[0]); 1
Change (arr);
Response.Write (Arr[0]); 2
The List namespace is System.Collections.Generic
list<int> list = new list<int> ();
List. ADD (1);
List. ADD (2);
List. ADD (3);
Response.Write (List[0]); 1
Change (list);
Response.Write (List[0]); 2
The namespace of the Array is the System
Array array = array.createinstance (System.Type.GetType ("System.Int32"), 3); Array is an abstract class and cannot be created using the new array.
Array. SetValue (1, 0);
Array. SetValue (2, 1);
Array. SetValue (3, 2);
Response.Write (Array. GetValue (0)); 1
Change (array);
Response.Write (Array. GetValue (0)); 2
The ArrayList namespace is system.collectio (www.111cn.net) NS
ArrayList ArrayList = new ArrayList (3);
Arraylist.add (1);
Arraylist.add (2);
Arraylist.add (3);
Response.Write (Arraylist[0]); 1
Change (arrayList);
Response.Write (Arraylist[0]); 2
}
private void Change (int[] arr)
{
for (int i = 0; i < arr. Length; i++)
{
Arr[i] *= 2;
}
}
private void Change (list<int> List)
{
for (int i = 0; i < list. Count; i++)//Use Count
{
List[i] *= 2;
}
}
private void Change (array array)
{
for (int i = 0; i < array. Length; i++)//Use Length
{
Array. An array of SetValue ((int). GetValue (i) * 2, I); Type conversions Required
}
}
private void Change (ArrayList ArrayList)
{
for (int i = 0; i < Arraylist.count; i++)//Use Count
{
Arraylist[i] = (int) arraylist[i] * 2; Type conversions Required
}
}
}
[] is for a specific type, fixed length.
List is for a specific type, any length.
The Array is for any type, fixed length.
The ArrayList is for any type, any length.
Arrays and ArrayList are implemented by storing objects of any type, so they are used to convert
From:http://www.111cn.net/net/160/40651.htm
C # Array of [], List, array, ArrayList applications