forum

home / developersection / forums / how to convert jagged array to 2d array?

How to convert jagged array to 2D array?

Royce Roy 3089 17-Dec-2013

I have a file file.txt with the following:

6,73,6,71

32,1,0,12

3,11,1,134

43,15,43,6

55,0,4,12

And this code to read it and feed it to a jagged array:

    string[][] arr =new string[5][];
    string[] filelines= File.ReadAllLines("file.txt");
    for (int i = 0; i< filelines.Length; i++)
    {
        arr[i] =filelines[i].Split(',').ToArray();
    }

How would I do the same thing, but with a 2D array?


c# c# 
Updated on 17-Dec-2013
Royce Roy

Other


Message
Can you answer this question?

Answer

1 Answers

Liked By