title: MarshalAs question in C#
body: <p>I'm having trouble receiving data from an external dll routine. The dll is to read data from a mirco-controller chip.  This works fine in Delphi,and I'm trying to get it to work in C#. </p>
  
  <p>Adr: Starting address
  Len: Total length of the data being read</p>
  
  <p>The function returns a TData array where the item with index 0 contains the starting
  address and the item with index 1 contains the length of the data received. Following
  items (index 2 and higher) contain the data received. If the Receive operation fails, the
  length value returned in the array is set to zero</p>
  
  <pre><code>  [DllImport("dsio.dll", CallingConvention = CallingConvention.StdCall)]
    [return: MarshalAs(UnmanagedType.LPArray)]
    public static extern byte[] Receive(int Adr, int Len);
  
    private void BtnReceive_Click(object sender, EventArgs e)
       {
           byte[] Data = new byte[256];
           int Adr = 0x05;
           int Len = 8;
  
           Data = Receive(Adr, Len);
           txtBox2.Text = Data;
       }
  </code></pre>