Converting List <List <string [] >> to string [] [] [] in C #

When creating web services in C #, I found it very useful to pass back arrays with notches, that is, the string [] []

I also found a neat trick to create them in a simple way in my code, which was to create a list and convert it by executing a ToArray () call.

eg.

public string[][] myws() {
    List<string[]> output = new List<string[]>();
    return output.ToArray();
}

I would like to be able to use a similar solution, but I can’t figure out how to do something similar with a 3-dimensional array or the string [] [] [], without resorting to loops and the like.

Relations Martin

+5
source share
1 answer

, Select(), List<string> ToArray(), ToArray():

        var x = new List<List<string[]>>();

        string[][][] y = x.Select(a => a.ToArray()).ToArray();

, .

+6

All Articles