title: C# byte array to string, and vice-versa
body: <p>I have some C++ code that persists byte values into files via STL strings &amp; text i/o, and am confused about how to do this in C#.  </p>
  
  <p>first I convert byte arrays to strings &amp; store each as a row in a text file:</p>
  
  <pre><code> StreamWriter F
   loop
   {
     byte[] B;       // array of byte values from 0-255 (but never LF,CR or EOF)
     string S = B;   // I'd like to do this assignment in C# (encoding? ugh.) (*)
     F.WriteLine(S); // and store the byte values into a text file
   }
  </code></pre>
  
  <p>later ... I'd like to reverse the steps and get back the original byte values:</p>
  
  <pre><code>  StreamReader F;   
    loop
    {
      string S = F.ReadLine();   // read that line back from the file
      byte[] B = S;              // I'd like to convert back to byte array (*)
    }
  </code></pre>
  
  <p>How do you do those assignments (*) ?</p>