Multiple choice technology programming languages

It is possible to write the simple types directly to a binary file using the methods in the FileStream class.

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

FileStream is a low-level stream class for reading and writing bytes. To write simple types (int, string, etc.) directly to a binary file, you need BinaryWriter or use serialization with FileStream. FileStream's Write methods only accept byte arrays, not typed data.

AI explanation

The statement is False. FileStream's own Read/Write methods only operate on bytes or byte arrays — it has no methods that natively serialize simple types like int, double, or bool. To write such simple types directly to a binary file you wrap the FileStream in a BinaryWriter (or BinaryReader for reading), which provides the type-specific Write(int), Write(double), etc. overloads.