title: c# reading/writing bytes to/from console
body: <p>I have a <code>byte[]</code> array and want to write it to stdout: <code>Console.Out.Write(arr2str(arr))</code>. How to convert <code>byte[]</code> to string, so that <code>app.exe &gt; arr.txt</code> does the expected thing? I just want to save the array to a file using a pipe, but encodings mess things up.</p>
  
  <p>I'd later want to read that byte array from stdin: <code>app.exe &lt; arr.txt</code> and get the same thing.</p>
  
  <p>How can I do these two things: write and read byte arrays to/from stdin/stdout?</p>
  
  <p>EDIT:</p>
  
  <p>I'm reading with <code>string s = Console.In.ReadToEnd()</code>, and then <code>System.Text.Encoding.Default.GetBytes(s)</code>. I'm converting from array to string with <code>System.Text.Encoding.Default.GetString(bytes)</code>, but this doesn't work when used with <code>&lt;</code>,<code>&gt;</code>. By "doesn't work" I mean that writing and reading over a pipe does not return the same thing.</p>