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 :: creating a streamwiter file C# 
Csharp :: asp.net textarea disable resize 
Csharp :: adding values to mock IHttpContextAccessor unit test .net core 
Csharp :: get list length c# 
Csharp :: system linq c# 
Csharp :: c# read csv file 
Csharp :: json property c# 
Csharp :: how to deactivate an object unity 
Csharp :: get color of pixel c# 
Csharp :: c# multiple strings are empty 
Csharp :: c# object list attribute to string 
Csharp :: constructor c# 
Csharp :: c# list foreach 
Csharp :: .net mvc return a specific View 
Csharp :: c# enum 
Csharp :: c# public static string 
Csharp :: how to acivate a game object unity 
Csharp :: c# get process file location 
Csharp :: c# close form 
Csharp :: linq when name then orderby 
Csharp :: c# wpf get clipboard text 
Csharp :: unity rigid body variable 
Csharp :: what is unity 
Csharp :: combobox selected name c# 
Csharp :: yield c# 
Csharp :: how to set the value of a textbox textmode=date asp.net c# 
Csharp :: how to insert value to identity column using entity framwork 
Csharp :: C# compare date values 
Csharp :: linq datatable 
Csharp :: c# entity framework get all records from table 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =