Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

How to obtain a string[,] or int[,] from a file with integer values

$
0
0

I have a file with array of values as

 
   0   0   0   0   1   1   1   1   0   0   0   0   1   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
   0   0   0   1   1   1   1   1   0   1   1   1   1   1   1   1   1   0   0   0   0   0   0   0   0   0   0   0   0   
   1   1   1   1   1   1   1   0   1   1   1   1   1   1   1   1   0   0   0   0   0   0   0   0   0   0   0   1   0

I need to read that file and get the value of each row and column and store it in a string[,] or int[,] currently I am trying to achieve this like this but not working .Any advice is appreciated

using (StreamReader reader =  new StreamReader(File.Open(Filename, FileMode.Open)))
            {
                string line;
                string[] columns;
                while ((line = reader.ReadLine()) != null)
                {
                    int r, c;
                    for (r = 0; r <= 599; r++)
                    {
                        for (c = 0; c <= 599; c++)
                        {
                            columns = line.Split(' ');
                            foreach (string value in columns)
                            {
                                if (value != "")
                                {
                                    Cycles[r, c] = value;
                                }
                            }
                        }
                    }
                }
            }



sudhansh


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>