Javatpoint Logo
Javatpoint Logo

C# StreamWriter

C# StreamWriter class is used to write characters to a stream in specific encoding. It inherits TextWriter class. It provides overloaded write() and writeln() methods to write data into file.

C# StreamWriter example

Let's see a simple example of StreamWriter class which writes a single line of data into the file.

Output:

File created successfully...

Now open the file, you will see the text "hello c#" in output.txt file.

output.txt:

hello c#
Next TopicC# StreamReader




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA