Why, when used BinaryFormatterto convert Int32to, byte[]should I get an array of length not 4 bytes?
static class Program
{
static void Main(string[] args)
{
var bf = new BinaryFormatter();
using(var ms = new MemoryStream())
{
bf.Serialize(ms, 42);
Console.WriteLine($"{ms.ToArray().Length} bytes");
}
Console.ReadLine();
}
}
Output:
54 bytes
source
share