Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert List<int>to List<List<int>>

Can i convert List<int>to List<List<int>> in c#? When I use such construction

List<int>element=new List<int>();
List<List<int>>superElement= new List<List<int>>(element);

I get a fault,but can I do this in another way?

like image 579
Mykhailo Vashchuk Avatar asked Apr 10 '13 09:04

Mykhailo Vashchuk


People also ask

How to convert list int to int?

int[] ints = Ints. toArray(list);

How do you convert a list of strings to a list of integers in python?

The most Pythonic way to convert a list of strings to a list of ints is to use the list comprehension [int(x) for x in strings] . It iterates over all elements in the list and converts each list element x to an integer value using the int(x) built-in function.


1 Answers

You can do it like this:

List<List<int>> superElement = new List<List<int>>();
superElement.Add(element);
like image 71
Nolonar Avatar answered Oct 05 '22 12:10

Nolonar