METHOD
Stream.Read
Reads up to count bytes, advances the stream by the number returned, and may return fewer bytes than requested. Zero for a positive count means end of stream. ReadExactly is appropriate for fixed-length records.
Formal Syntax & Structure
csharp syntaxcsharp
stream.Read(buffer, offset, count)Working Example
Example Snippetcsharp
using System;using System.IO;using System.Collections.Generic;using System.Text.Json;using var s = new MemoryStream(new byte[] { 4, 5 }); var b = new byte[3]; Console.WriteLine(s.Read(b,0,3)); // 2