Different values when ANDING and assigned uints to a char array in C++ and C#
<p>I have a very simple problem that is giving me a really big headache in that I am port a bit of code from C++ into C# and for a very simple operation I am getting totally different results:-</p>

<p>C++</p>

<pre><code>char OutBuff[25];       
int i;
unsigned int SumCheck = 46840;

OutBuff[i++] = SumCheck &amp; 0xFF; //these 2 ANDED make 248
</code></pre>

<p>The value written to the char array is -8</p>

<p>C#</p>

<pre><code>char[] OutBuff = new char[25]; 
int i;
uint SumCheck = 46840;
OutBuff[i++] = (char)(sumCheck &amp; 0xFF); //these 2 ANDED also make 248
</code></pre>

<p>The value written to the char array is 248.</p>

<p>Interestingly they are both the same characters, so this may be something to do with the format of a char array in C++ and C# - but ultimately I would be grateful if someone could give me a definitive answer.</p>

<p>Thanks in advance for any help.</p>

<p>David</p>
