C# StreamWriter Encoding

Description

StreamWriter Encoding Gets the Encoding in which the output is written.

Syntax

StreamWriter.Encoding has the following syntax.


public override Encoding Encoding { get; }

Example

The following example retrieves the encoding of the specified StreamWriter instance.


/*from ww  w  . j  a va  2s  .co m*/
using System.IO;
using System;
public class MainClass{
  public static void Main(String[] argv){  
    StreamWriter sw = new StreamWriter("abc.txt");
    Console.WriteLine(sw.Encoding.ToString());
    

  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter