A two-dimensional array, a set of rectangular arrays
two-dimensional array, rectangular array Collection
a . Two-dimensional arrays:
One-dimensional array---beans
Two-dimensional array---table
1) Definition:
One-dimensional arrays:
data type [] array variable name = new data type [array length];
data type [] array variable name = new data type [array length]{1,2,3 ...};
2) Two-dimensional array:
data type [,] array variable name = new data type [number of rows, number of columns];
int[,] a = new int[3,4];
Assignment value:
a[row subscript, column subscript] = value subscript is starting from 0
Value:
a[row subscript, column subscript]
two . jagged data, an array of arrays.
Defined:
First step: Define a large Array
data type [] A = new data type [number of rows] [];
Step two: Define the decimal group
Data type [] a1 = new data type [number of columns];
Data type [] a2 = new data type [number of columns];
......
Step three: Put the decimal group in a large array
A[0] = A1;
A[1] = A2;
three . Collection
1 , ArrayList linked list, no length limit, can add or remove elements at any time .
Need to be preceded by: using System.Collections;
Defined:
ArrayList a = new ArrayList ();
Operation:
A.add (data): add
A.insert (index number, data): Insert
A.removeat (index number): delete
A.count the number of elements in the collection
Value:
a[Subscript]
The values taken out need to be cast
2 , list< type > linked list, with no length limit, can add or remove elements at any time. Only data of the specified type can be placed, and no casts are taken out.
Defined
list< type > variable name = new list< type > ();
List<int> a = new list<int> ();
Operation:
A.add (data): add
A.insert (index number, data): Insert
A.removeat (index number): delete
A.count the elements in a collection.
A two-dimensional array, a set of rectangular arrays