title: Convert byte array to string in C#
body: <p>I'm new to C# and I built an application that receives bytes from a Serial Port and parses the bytes.</p>
  
  <p>In one scenario, the application receives an array of bytes that represents a string. My idea is to convert the bytes to string ad visualise the string into a text box. </p>
  
  <p>With this code: </p>
  
  <pre><code>textSerialNumber.Text = Encoding.UTF8.GetString(readData.payload, 0, readData.payload.Length);
  </code></pre>
  
  <p>I obtain the string but there is a problem: the first byte receive on the serial port is a 0x00 ( it represents an ack ). When i convert the payload (ack + string ) the first character is a NULL and text box assignments fails.</p>
  
  <p>If I modify the code to start form the first element of the byte array: </p>
  
  <pre><code>textSerialNumber.Text = Encoding.UTF8.GetString(readData.payload, 1, readData.payload.Length);
  </code></pre>
  
  <p>Also in this case the text box assignment fails.</p>
  
  <p>I try to skip the text box assignment:</p>
  
  <pre><code>string x = Encoding.UTF8.GetString(readData.payload, 1, readData.payload.Length);
  </code></pre>
  
  <p>But also int this case the encoding fails.</p>
  
  <p>Any suggestion to find the error?</p>
  
  <p>Thanks in advance.</p>