static void Main()
// Create a new TextWriter in the resource acquisition statement.
//using (TextWriter writer = File.CreateText("C:\\perl.txt"))
// Write one line.
// Write two strings.
// Write the default newline.
StreamWriter. The StreamWriter class inherits from TextWriter. The TextWriter class is an abstract base class, which means it provides functionality for StreamWriter.
Note Microsoft states that StreamWriter represents writing in a particular encoding.
And For this reason, unless you have specialized encoding requirements, StreamWriter is more appropriate because it manages the encoding.
Summary. We looked at the TextWriter class and related it to the StreamWriter class by noting that it is used as a base class. TextWriter does not handle encodings automatically.