title: convert serialport.readline() non-ascii string into a byte array
body: <p>I want to use <strong>serialport.readline()</strong> because it's a blocking call and the data I'm getting has 0x0D 0x0A (CR LF) at the end. However, what I want is an Hex String instead of an Ascii representation.</p>
  
  <p>For example, the device I am communication with is sending byte arrays like {0xff,0xff,0x45,0x0D,0x0A}. I want to simply print out in my program just like this: 0xff, 0xff,0x45.  Readline() kindly trims out LF and CR.</p>
  
  <p>I though about using <strong>serialport.read(buff[]...)</strong> by specifying how many bytes I want to read. But it didn't work very well because if I am reading too fast half of the array will be 0x00 and if I am reading too slow, there will be an overflow for the com port. I don't want to lose any bytes. </p>
  
  <p>I tried to convert what I got from <strong>serialport.readline()</strong> to a byte array but the hex string I got usually turns into <strong>0x3f</strong>. Code is like this:</p>
  
  <pre><code>var line = string.Join(",", mySerialPort.ReadLine().Select(c =&gt; ((Byte)c).ToString("X")).ToArray());
  </code></pre>
  
  <p>I changed the encoding a few times (ASCII, UTF8,UNICODE) but still no go.</p>
  
  <p>Is there any way to convert the <strong>non-Ascii</strong> String I got from <strong>readline()</strong> into a byte array?</p>