c# - How to create a vector of strings from multi dimensional arrays? -
The basic problem is that I am reading a large chunk of binary data from a device that is developing.
My goal reading data and human readable text such as The csv file is to be parsed, so I have to adjust that data.
In the form of data samples, floating, long or ints or whatever, the multi-dimensional array, and because the device is under development, the size and dimension of the arrays can range from one hour to the hour!
(For example, now I can get samples of 2 * 2 metrics, from now on, change the data structure to an array of 1 * 4, or 16 * 12 * 128. .)
A part of the problem. Generate the header line of the CSV file. I need a method that can generate an array of strings like this: <2p> For 2: 2: data_0_0, data_0_1, data_1_0, data_1_1, and
1 * 4 : Data_0, 3 * 4 * 2: data_0_0_0, data_0_0_1, data_0_0_2, ...., data_2_3_0, data_2_3_1,
and so on, data_1, data_2, data_3,
And ...
Only from the tool all the time can I get that the information is dimension and size of the array. The tool can tell me {1}, which means a single value, {12} has an array of length 12, {3,4,5} means "3x4x5" element array and so on and so forth ... Therefore, I should be able to level any array of * b * c * .. * x (Which should not be too difficult because I can have one for loop.
Therefore, I would like to create a method that generates a vector of strings (in the format above) from a multi-dimensional array / P>
Therefore, I think that in the end, the method of generating the headers looks like something
public string [] generatname (string data block name, int [] dimension). {}
For a simple solution It is expected to say 10 for-loops and hope that raw data will never have an array which is more than 10 dimensions. However, I'm asking a better, cleaner, a lot of questions, how to convert vector into multi-dimensional arrays My goal is the exact opposite thing and a header line with unlimited flexibility!
Thank you very much before!
- The "bottomless first traversal" use of someone given below To do A suggestion has been given which I will now see. Early Goggling seemed promising.
Can be changed by simply typing in a foreach
loop, adding each item to the list, and then converting that list into an array.
Public T [] Flaton & lt; T & gt; (Array Array) {var list = new list & lt; T & gt; (); Foreign (array in T items) {list.Add (item); } Return List. Tore (); }
Where array
is a rectangular array of any size.