C# – How to change StreamWriter’s buffer size

StreamWriter buffers by writing data to an internal char array with a default size of 1024 (and a minimum size of 128). Once the buffer is full (or when you dispose the StreamWriter), it flushes the buffer to the underlying stream. You can change StreamWriter’s buffer size by passing in the bufferSize parameter. Here’s an … Read more

C# – Deserialize JSON as a stream

Here’s an example of deserializing JSON from a file as a stream with System.Text.Json: Stream deserialization has three main benefits: In this article, I’ll go into details about these benefits and show a few other stream serialization scenarios. Benefits of deserializing as a stream Performance There are two ways to deserialize JSON: Deserializing a stream … Read more