Stream

noun

say it: “STREEM” /striːm/

A connection to a source of data, such as a file, that hands over its data a piece at a time.

What is Stream in C#?

Stream — A connection to a source of data, such as a file or a network, that hands it over a piece at a time instead of all at once. A huge file can be read line by line without loading the whole thing into memory.

using StreamReader reader = new("books.csv");
string? line;
while ((line = reader.ReadLine()) != null)
{
    Console.WriteLine(line);
}

In a sentence

  • “Reading the 2 GB log as a stream used almost no memory.”

Level: Journeyman · More C# terms at this level

Updated

In other subjects