Using C Sharp: Part 2: File Input and Output

C Sharp Basics:

Using C#

C# is a multi-paradigm programming language created by Microsoft as part of the .Net initiative in 2000. It has gone on to have its own standard and become part of everything from desktop applications to used extensively in game development.


File Input and Output

Most file interactions in C# work through streams, a connection to a source of data. To work with files is to work through different types of streams. These are part of the File object in System.IO.

StreamReader

Streams can be read using the StreamReader type. (This is a more generalized stream reader type. To specifically deal with Text or Binary data, there is specialized TextReader and BinaryReader functionality.)

StreamWriter

To write data to a stream, the object StreamWriter can be used. (Like with StreamReader, there are also specialized objects for Text and Binary operations.)

Play with the example on Repl.it!