title: Read Serial Port on C# allocating on an array no forgetting "00"
body: <p>I'm trying to do a program that reads a serie of data from a serial port (COM3). The problem is that my code is for example (in decimal): </p>
  
  <blockquote>
    <p>170 85 01 128 01 129 46 00 00 00 00 00 05 46</p>
  </blockquote>
  
  <p>The way I'm reading the bytes "00" aren't been allocated on the array or variable:
  I try a lot of ways like:</p>
  
  <pre><code>await port.BaseStream.ReadAsync(buffer, 0, 1);
  </code></pre>
  
  <p>And like shows on microsoft web site:</p>
  
  <pre><code>using System;
  using System.IO.Ports;
  
  class PortDataReceived
  {
      public static void Main()
      {
          SerialPort mySerialPort = new SerialPort("COM1");
  
          mySerialPort.BaudRate = 9600;
          mySerialPort.Parity = Parity.None;
          mySerialPort.StopBits = StopBits.One;
          mySerialPort.DataBits = 8;
          mySerialPort.Handshake = Handshake.None;
          mySerialPort.RtsEnable = true;
  
          mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
  
          mySerialPort.Open();
  
          Console.WriteLine("Press any key to continue...");
          Console.WriteLine();
          Console.ReadKey();
          mySerialPort.Close();
      }
  
      private static void DataReceivedHandler(
                          object sender,
                          SerialDataReceivedEventArgs e)
      {
          SerialPort sp = (SerialPort)sender;
          string indata = sp.ReadExisting();
          Console.WriteLine("Data Received:");
          Console.Write(indata);
      }
  }
  </code></pre>
  
  <p>But all this methods doesn't work.
  Does any one knows any way from get this data and allocate in an array?</p>