title: Convert short to int
body: <p>I need to convert a short from the packet header to an integer, what would be the way without affecting its value? Is there anything else I can do?</p>
  
  <pre><code>private async void ParsePackets(StreamSocket socket)
  {
      using (IInputStream input = socket.InputStream)
      {
          byte[] data = new byte[BufferSize];
          IBuffer buffer = data.AsBuffer();
          uint dataRead = BufferSize;
  
          // Wait for payload size
          while (data.Length &lt; 4)
          {
              await input.ReadAsync(buffer, BufferSize, InputStreamOptions.Partial);
              dataRead = buffer.Length;
  
              short payloadSizeShort = 0;
              // Cannot convert from short to system array
              System.Buffer.BlockCopy(data, 2, payloadSizeShort, 0, 2);
  
              int payloadSize = (int)payloadSizeShort;
  
              // Wait for full message
              while (data.Length &lt; (PacketHeaderSize + payloadSize))
              {
                  // Block copy
                  // Delete message bytes from buffer
                  // Break
              }
          }
  
  
      }
  }
  </code></pre>