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





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA