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#
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.