Convert piece of code from c++ to c#
<p>i'm trying to convert code from c++ to c#.. but i'm stuck.
Can somebody let me know where i'm wrong?</p>

<p>C++ code is:</p>

<pre><code>void CALLBACK Test(void *buffer, DWORD length)
{
  BYTE *b=(BYTE*)buffer, temp[20000];
  DWORD p=0;
  while (p&lt;length) 
  {
    DWORD c=min(length-p, sizeof(temp));
    memcpy(temp, b+p, c);
    c=SendData(dummy, temp, c);
    if (c==-1) break;
    p+=c;
  }
}

where is SendData(int, byte[], int)
</code></pre>

<p>And current c# code</p>

<pre><code>void Test(IntPtr buffer, int length)
{

        byte[] temp = new byte[20000];
        byte[] b = new byte[length];
        Marshal.Copy(buffer, b, 0, length);

   long p=0;
   while (p&lt;length) 
   {
    long c=Math.Min(length-p, 20000);
    Array.Copy(temp, b+p, c);
    c=SendData(dummy, temp, (int)c);
    if (c==-1) break;
    p+=c;
  }
}
</code></pre>

<p>I'm not sure did I did it correctly, but I can see I cannot apply operator <code>+</code> to <code>b+s</code> because it's <code>long</code> and <code>byte[]</code>.</p>

<p>Thanks</p>
