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?
int[] ints = Ints. toArray(list);
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.
You can do it like this:
List<List<int>> superElement = new List<List<int>>();
superElement.Add(element);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With