Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# 2d list

//This code is an updated, working version of the code Tender Termite wrote

List<List<int>> matrix = new List<List<int>>();  //Create 2d List
List<int> list1 = new List<int>();
list1.Add(4);
list1.Add(5);
matrix.Add(list1);	//Insert List into matrix
List<int> list2 = new List<int>();
list2.Add(6);
list2.Add(7);
matrix.Add(list2);

int x = matrix[0][1];	//Get data from Matrix, here x is 5

matrix[0].RemoveAt(1);  //Removes the 5
x = matrix[0][0];		//x is now 4

matrix.RemoveAt(0);		//removes whole first row

x = matrix[0][1];		//x is now 7
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #list
ADD COMMENT
Topic
Name
7+6 =