int[] to string c#
<p>Hi I'm developing an client application in C# and the server is written in c++</p>

<p>the server uses:</p>

<pre><code>inline void StrToInts(int *pInts, int Num, const char *pStr)
{
  int Index = 0;
  while(Num)
  {
    char aBuf[4] = {0,0,0,0};
    for(int c = 0; c &lt; 4 &amp;&amp; pStr[Index]; c++, Index++)
      aBuf[c] = pStr[Index];
    *pInts = ((aBuf[0]+128)&lt;&lt;24)|((aBuf[1]+128)&lt;&lt;16)|((aBuf[2]+128)&lt;&lt;8)|(aBuf[3]+128);
    pInts++;
    Num--;
  }

  // null terminate
  pInts[-1] &amp;= 0xffffff00;
}
</code></pre>

<p>to convert an string to int[]</p>

<p>in my c# client i recieve:</p>

<pre><code>int[4] { -14240, -12938, -16988, -8832 }
</code></pre>

<p>How do I convert the array back to an string?
I don't want to use unsafe code (e.g. pointers)
Any of my tries resulted in unreadable strings.</p>

<p>EDIT:
Here is one of my approch:</p>

<pre><code>private string IntsToString(int[] ints)
{
  StringBuilder s = new StringBuilder();
  for (int i = 0; i &lt; ints.Length; i++)
  {
    byte[] bytes = BitConverter.GetBytes(ints[i]);
    for (int j = 0; j &lt; bytes.Length; j++)
      s.Append((char)(bytes[j] &amp; 0x7F));
  }
  return s.ToString();
}
</code></pre>

<p>I know I need to take care of endianess but as the server is running on my local machine and the server too, I assume that this is not a problem.<br>
My other try was to use an struct with explicit layout and same FieldOffset for integer and chars but it doesn't work, either.</p>
