473,508 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

List of lists to multidimension array

2 New Member
I need to convert

List<List<MyClass>> tracks = new List<List<MyClass>>(nCount);

to a jagged array.

something like...

MyClass[][] foo = tracks.ToArray();
Feb 23 '10 #1
2 8646
ThatThatGuy
449 Recognized Expert Contributor
hey you can't directly assign like that....

but you can do something like this...

Expand|Select|Wrap|Line Numbers
  1.     List<List<string>> lst = new List<List<string>>();
  2.             string[,] str = new string[lst.Count, lst[0].Count];
  3.             for (int j = 0; j < lst.Count; j++)
  4.             {
  5.                 for (int i = 0; i < lst[j].Count; i++)
  6.                 {
  7.                     str[j, i] = lst[j][i].ToString();
  8.                 }
  9.             }
  10.  
Feb 23 '10 #2
e930194
2 New Member
It works fine for multidimensional arrays but not for jagged arrays.
i.e. it works fine for string[,] but not string[][]
I do apologise for the title reading multidimensional arrays. I only realised my mistake afterwards.
Anyways you answer put me on the road to my solution. Thanks
Feb 23 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

21
4288
by: Hilde Roth | last post by:
This may have been asked before but I can't find it. If I have a rectangular list of lists, say, l = ,,], is there a handy syntax for retrieving the ith item of every sublist? I know about for i...
7
2368
by: Adam Hartshorne | last post by:
As a result of a graphics based algorihtms, I have a list of indices to a set of nodes. I want to efficiently identify any node indices that are stored multiple times in the array and the...
7
2031
by: Jim Lewis | last post by:
I'm trying to move a function into pyrex for speed. The python side needs to pass a list to the pyrex function. Do I need to convert to array or something so pyrex can generate tight code? I'm not...
5
2268
by: bruce | last post by:
hi... i'm trying to deal with multi-dimension lists/arrays i'd like to define a multi-dimension string list, and then manipulate the list as i need... primarily to add lists/information to the...
1
2231
by: Stephene | last post by:
New to the world of web design/php/mysql and need help please. What I'm trying to do: I would like a web page with three drop down menus each populated by a query The first represents...
45
18764
by: Zytan | last post by:
This returns the following error: "Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.this' because it is not a variable" and I have no idea why! Do lists return copies...
2
1880
by: Rob | last post by:
Hi, I want to create an arraylist of multidimension arrays. Currently I've managed to do these via conventional means as follows: Dim myarraylist As ArrayList = New ArrayList() Dim...
8
718
by: dmp | last post by:
What are Linked list? Please somebody show some ready made programs of linked list
10
11193
by: J. Peng | last post by:
what's the difference between an array and a list in python? I see list has all features of array in C or perl. so please tell me.thanks.
36
2860
by: pereges | last post by:
Hi, I am wondering which of the two data structures (link list or array) would be better in my situation. I have to create a list of rays for my ray tracing program. the data structure of ray...
0
7227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7331
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7391
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.