title: C# - Placing the characters of a text file into a 2D Array
body: <p>I want to take the contents of a text file and place it into a 2D array, character by character. I have included an example below</p>
  
  <p>Text File</p>
  
  <pre><code>ABCDE
  FGHIJ
  KLMOP
  </code></pre>
  
  <p>2D Array (Char Array)</p>
  
  <pre><code>[
   [A,B,C,D,E]
   [F,G,H,I,J]
   [K,L,M,O,P]
  ]
  </code></pre>
  
  <p>What would be the best way of going about this? For the time being I am assuming that the length of the text file is also the width (in Char), I will fix it up later!</p>
  
  <pre><code>OpenFileDialog openFile1 = new OpenFileDialog();
  string sFileName = openFile1.FileName;
  
  int lineCount = File.ReadLines(sFileName).Count();
  
  char[,] letters = new char[lineCount,lineCount];
  </code></pre>