METHOD
Stream.ReadByte
Returns the next byte as an int in 0 through 255, or -1 at end of stream. Test the sentinel before converting to byte.
Formal Syntax & Structure
csharp syntaxcsharp
stream.ReadByte()Working Example
Example Snippetcsharp
using System;using System.IO;using System.Collections.Generic;using System.Text.Json;using var s = new MemoryStream(new byte[]{255}); Console.WriteLine(s.ReadByte()); Console.WriteLine(s.ReadByte()); // 255 then -1