You told it to read an Int32 with ReadInt32
, and an Int32
is 4 bytes (32 bits). So you said "Read a four byte (32-bit) integer", and it did exactly what you told it to do.
The same thing happened when you used bw.write(i);
- as you said, i
is an integer, and you told it to write an integer. Since the default integer is 4 bytes (32 bits) on your platform, it wrote 4 bytes.