Let's consider this piece of code :
static void Main(string[] args)
{
Console.WriteLine(Marshal.SizeOf(typeof(bool)));
Console.WriteLine(String.Join(", ", BitConverter.GetBytes(true)));
}
if bool is 1 byte, I'd expect it to output
1
1
and if bool is 4 bytes (as an int), I'd expect
4
1, 0, 0, 0 // let's forget about the endianness
However, it outputs (in x64)
4
1
That's quite an issue for me in marshaling code. Who should I trust?