reccomendations for learning how to work with streams.
Im trying to dive deeper into how streams work in C# but i find it hard to jugde what source is a good source to learn from. does anyone have good reccomendations?
8 Replies
the official documentation is a good place to start https://learn.microsoft.com/en-us/dotnet/api/system.io.stream?view=net-8.0
Stream Class (System.IO)
Provides a generic view of a sequence of bytes. This is an abstract class.
thanks 👍
You can start with MemoryStreams and use a predictable set of data and see how it's read and how streaming api's typically work.
MemoryStream Class (System.IO)
Creates a stream whose backing store is memory.
There's a note about IDisposable in the middle of that page btw, you should totally ignore it.
so i should dispose of memory streams?
for memory streams there's nothing to dispose, the backing store is just an array
other kinds of streams like network streams may be holding onto other resources like a socket that need to be disposed
There's no consequence to not disposing of memory streams, but it's a bad practice to not dispose streams; there's also no reason not to.