HI WELCOME TO SIRIS

C# TextWriter

Leave a Comment
C# TextWriter class is an abstract class. It is used to write text or sequential series of characters into file. It is found in System.IO namespace.

C# TextWriter Example

Let's see the simple example of TextWriter class to write two lines data.
  1. using System;  
  2. using System.IO;  
  3. namespace TextWriterExample  
  4. {  
  5.     class Program  
  6.     {  
  7.         static void Main(string[] args)  
  8.         {  
  9.             using (TextWriter writer = File.CreateText("e:\\f.txt"))  
  10.             {  
  11.                 writer.WriteLine("Hello C#");  
  12.                 writer.WriteLine("C# File Handling by JavaTpoint");  
  13.             }  
  14.             Console.WriteLine("Data written successfully...");  
  15.         }  
  16.     }  
  17. }  
Output:
Data written successfully...
f.txt:
Hello C#
C# File Handling by JavaTpoint

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.