C
C#2y ago
Stroniax

✅ How Does StreamReader.ReadLine Know When to Stop?

I am working with streams and don’t want to grab more data than I need from the stream. I realized somehow a streamreader knows when to stop reading, but I can’t imagine it reads one byte at a time to find the terminator character. How does it know when it has read enough and not consume more of the buffer?
1 Reply
jcotton42
jcotton422y ago
GitHub
runtime/StreamReader.cs at main · dotnet/runtime
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps. - runtime/StreamReader.cs at main · dotnet/runtime

Did you find this page helpful?