title: Decode byte array
body: <p>I want to decode a byte array received from a modbus communication. This is the hex string representing the byte array:</p>
  
  <pre><code>01 11 0C 46 57 35 32 39 37 30 31 52 30 2E 35 FE 27
  </code></pre>
  
  <p>I want to split in 3 parts:</p>
  
  <ol>
  <li>01 11 0C</li>
  <li>46 57 35 32 39 37 30 31 52 30 2E 35</li>
  <li>FE 27</li>
  </ol>
  
  <p>For transforming from byte to hex I use this method:</p>
  
  <pre><code> #region ByteToHex
      /// &lt;summary&gt;
      /// method to convert a byte array into a hex string
      /// &lt;/summary&gt;
      /// &lt;param name="comByte"&gt;byte array to convert&lt;/param&gt;
      /// &lt;returns&gt;a hex string&lt;/returns&gt;
      public string ByteToHex(byte[] comByte)
      {
          //create a new StringBuilder object
          StringBuilder builder = new StringBuilder(comByte.Length * 3);
          //loop through each byte in the array
          foreach (byte data in comByte)
              //convert the byte to a string and add to the stringbuilder
              builder.Append(Convert.ToString(data, 16).PadLeft(2, '0').PadRight(3, ' '));
          //return the converted value
          return builder.ToString().ToUpper();
      }
  </code></pre>
  
  <p>How can I split the returned string from that method to return:
  the first 3 bytes are:</p>
  
  <ol>
  <li>Server id</li>
  <li>Function code</li>
  <li>Byte count</li>
  </ol>
  
  <p>The next N bytes (see 3.) are the payload; the last 2 are a CRC16.</p>
  
  <p>I need to find the payload; it is a string.</p>