Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

2d list in c#

List<List<int>> list = new List<List<int>>{
         new List<int> { 1, 2, 3 },
         new List<int> { 4, 5, 6 },
         new List<int> { 9, 8, 9 }
};
Comment

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
Comment

2d list c#

List<List<int>> matrix = new List<List<int>>();
List<int> list1 = new List<int>();
list1.Add("4");
list1.Add("5");
matrix.Add(list1);
List<int> list2 = new List<int>();
list2.Add("6");
list2.Add("7");
matrix.Add(list2);

//matrix is now
// 4 5
// 6 7
Comment

c# 2d list


List<string> track = new List<string>();
track.Add("2349");
track.Add("The Prime Time of Your Life");
// etc
matrix.Add(track);

Comment

PREVIOUS NEXT
Code Example
Csharp :: c# socket connect timeout 
Csharp :: unity destroy after time 
Csharp :: unity cos 
Csharp :: c# get getter set setter method 
Csharp :: int value from enum in C# 
Csharp :: c# making a folder 
Csharp :: list all files in directory and subdirectories c# 
Csharp :: csharp sleep code 1 second 
Csharp :: c# string to byte[] 
Csharp :: unity log error 
Csharp :: c# string replace comma with newline 
Csharp :: string reverse c# 
Csharp :: google sheet script change text color 
Csharp :: switch case c# contains 
Csharp :: c# datagridview selected row index 
Csharp :: c# enum to int 
Csharp :: unity how to move an object 
Csharp :: how to check if a path is a directory or file c# 
Csharp :: c# contains 
Csharp :: unity get perlin noise 3d 
Csharp :: joystock movement 
Csharp :: add variable to the beginning of a list c# 
Csharp :: {"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."} 
Csharp :: c# cancellationtoken example 
Csharp :: c# concatenation 
Csharp :: c# isarray 
Csharp :: c# convert datetime to unix timestamp 
Csharp :: datetime check null c# 
Csharp :: get list length c# 
Csharp :: toggle unity c# 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =