Binary Reading & Writing

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/28

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:35 AM on 8/14/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

29 Terms

1
New cards

BinaryReader

A class in System.IO that reads primitive data types and strings from an underlying stream in binary form. Domain: C# → .NET → System.IO → Binary I/O

2
New cards

BinaryWriter

A class in System.IO that writes primitive data types and strings to an underlying stream in binary form.

3
New cards

Binary I/O

Reading or writing data according to its binary representation rather than treating the underlying bytes as ordinary lines of text.

4
New cards

new BinaryReader(stream)

Creates a BinaryReader that reads binary data from the specified Stream.

5
New cards

new BinaryReader(stream, encoding)

Creates a BinaryReader using a specified character encoding when decoding strings and characters contained in the binary data.

6
New cards

new BinaryWriter(stream)

Creates a BinaryWriter that writes binary data to the specified Stream.

7
New cards

new BinaryWriter(stream, encoding)

Creates a BinaryWriter using a specified character encoding when encoding strings and characters.

8
New cards

reader.ReadBoolean()

Reads a Boolean value from the current stream.

9
New cards

reader.ReadByte()

Reads the next byte from the current stream.

10
New cards

reader.ReadInt16()

Reads a 2-byte signed integer from the current stream.

11
New cards

reader.ReadInt32()

Reads a 4-byte signed integer from the current stream.

12
New cards

reader.ReadInt64()

Reads an 8-byte signed integer from the current stream.

13
New cards

reader.ReadSingle()

Reads a 4-byte single-precision floating-point value from the current stream.

14
New cards

reader.ReadDouble()

Reads an 8-byte double-precision floating-point value from the current stream.

15
New cards

reader.ReadDecimal()

Reads a Decimal value from the current stream.

16
New cards

reader.ReadChar()

Reads the next character from the current stream according to the reader's character encoding.

17
New cards

reader.ReadString()

Reads a length-prefixed string from the current stream using the reader's character encoding.

18
New cards

reader.BaseStream

Gets the underlying Stream used by the BinaryReader.

19
New cards

writer.Write(value)

Writes a value to the underlying stream in the binary representation associated with the value's type.

20
New cards

writer.Flush()

Clears BinaryWriter's buffers by writing buffered data to the underlying stream.

21
New cards

writer.BaseStream

Gets the underlying Stream used by the BinaryWriter.

22
New cards

Binary Write/Read Order

Binary values must generally be read according to the same format, type sequence, and order in which they were written.

23
New cards

BinaryWriter String Format

BinaryWriter.Write(string) writes an encoded string preceded by length information that BinaryReader.ReadString() uses when reading it back.

24
New cards

BinaryReader End of Data

Attempting to read a required value when insufficient data remains can cause an EndOfStreamException.

25
New cards

BinaryReader Disposal

Disposing a BinaryReader normally disposes its underlying stream unless the reader was configured to leave the stream open.

26
New cards

BinaryWriter Disposal

Disposing a BinaryWriter normally disposes its underlying stream unless the writer was configured to leave the stream open.

27
New cards

leaveOpen

A constructor option that allows the underlying stream to remain open after a BinaryReader or BinaryWriter is disposed.

28
New cards

BinaryReader/BinaryWriter Pair

BinaryWriter serializes supported primitive values to a stream and BinaryReader reconstructs those values when the same binary format is followed.

29
New cards

Binary I/O vs Text I/O

BinaryReader and BinaryWriter operate on typed binary representations, whereas StreamReader and StreamWriter convert between encoded bytes and human-readable text.