Reading in a File 2D Arrays
I have to code a program that will read in a 2D array of 9 x 9 integers from a file that represents a Sudoku board solution
My goals are to
Usually, the goal when reading in a file is to do the following
(Writing code to select the file)
(My code for this 2D array, I get an error when setting SudokuBoard to Records): https://paste.mod.gg/ttybylvutrvb/0
https://paste.mod.gg/gokonoflypqv/0( here is how I normally code it in)
Anyone have ideas on how I code it in to read in the file?
My goals are to
- Read in the file and display it on the form (it is a text file)
- After this, I have to write a validator for the solution
Usually, the goal when reading in a file is to do the following
(Writing code to select the file)
- OpenFileDialog oFD = new OpenFileDialog();
- if (oFD.ShowDialog() == DialogResult.OK)
(File selected so open to read it) - StreamReader oSR = new StreamReader(oFD.OpenFile());
- int Records = int.Parse(oSR.ReadLine());
(Initializing the arrays) - Set array = new int [Records];
- for (int i = 0; i < array.length; i++)
Array[i] = int.Parse(oSR.ReadLine());
This is the procedure I usually go through to read in a file
(My code for this 2D array, I get an error when setting SudokuBoard to Records): https://paste.mod.gg/ttybylvutrvb/0
https://paste.mod.gg/gokonoflypqv/0( here is how I normally code it in)
Anyone have ideas on how I code it in to read in the file?


A tool for sharing your source code with the world!
A tool for sharing your source code with the world!