Article From:https://www.cnblogs.com/xwqfa/p/9967514.html

The most significant difference is that once an array is initialized, the number of elements in the array can not be changed; List< T> is a set, and the number of elements in the set can be changed dynamically.

For example:

1
2
// array
int[] a = new int[3];  //Array a can hold only three int-type values

Once the array is initialized, the number of elements is fixed. In subsequent operations, it is not allowed to increase or decrease the number of elements.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
//List<int>aggregate
List<int> list = new List<int>(); //Initially, the element in the list is 0
//Additive elements
list.Add(1);
list.Add(2);
list.Add(3);  // listThere are three elements of type int
//Continue to add elements
list.Add(100);
list.Add(200);
list.Add(300); //listThere are six elements of type int
//Delete the first element, that is, delete the element whose value is equal to 1
list.RemoveAt(0);  //listThere are 5 elements in it.
//Delete all elements
list.Clear();      //listThe median number of elements is 0.

The number of elements in a list set is dynamically variable!

 

 http://www.xinli001.com/info/100413285

Leave a Reply

Your email address will not be published. Required fields are marked *