title: Reading an int from a file returns ASCII
body: <p>I'm currently making a game but I seem to have problems reading values from a text file.  For some reason, when I read the value, it gives me the ASCII code of the value rather than the actual value itself when I wrote it to the file.  I've tried about every ASCII conversion function and string conversion function, but I just can't seem to figure it out.</p>
  
  <p>I use a 2D array of integers.  I use a nested for loop to write each element into the file.  I've looked at the file and the values are correct, but I don't understand why it's returning the ASCII code.  Here's the code I'm using to write and read to file:</p>
  
  <p>Writing to file:</p>
  
  <pre><code>for (int i = 0; i &lt; level.MaxRows(); i++)
  {
      for (int j = 0; j &lt; level.MaxCols(); j++)
      {
          fileWrite.Write(level.GetValueAtIndex(i, j) + " ");
          //Console.WriteLine(level.GetValueAtIndex(i, j));
      }
  
      //add new line
      fileWrite.WriteLine();
  }
  </code></pre>
  
  <p>And here's the code where I read the values from the file:</p>
  
  <pre><code>string str = "";
  int iter = 0;    //used to iterate in each column of array
  
  for (int i = 0; i &lt; level.MaxRows(); i++)
  {
      iter = 0;
      //TODO: For some reason, the file is returning ASCII code, convert to int
      //keep reading characters until a space is reached.
      str = fileRead.ReadLine();
  
      //take the above string and extract the values from it.
      //Place each value in the level.
      foreach (char id in str)
      {
          if (id != ' ')
          {
              //convert id to an int
              num = (int)id;
              level.ChangeTile(i, iter, num);
              iter++;
          }
      }
  </code></pre>
  
  <p>This is the latest version of the loop that I use to read the values. Reading other values is fine; it's just when I get to the array, things go wrong.  I guess my question is, why did the conversion to ASCII happen?  If I can figure that out, then I might be able to solve the issue.  I'm using XNA 4 to make my game.</p>