Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

StringWriter.Encoding Property

Gets the Encoding in which the output is written.

[Visual Basic]
Overrides Public ReadOnly Property Encoding As Encoding
public override Encoding Encoding {get;}
public: __property Encoding* get_Encoding();
public override function get Encoding() : Encoding;

Property Value

The Encoding in which the output is written.


This property is necessary for some XML scenarios where a header must be written containing the encoding used by the StringWriter. This allows the XML code to consume an arbitrary StringWriter and generate the correct XML header.

The following table lists examples of other typical or related I/O tasks.

To do this... See the example in this topic...
Create a text file. Writing Text to a File
Write to a text file. Writing Text to a File
Read from a text file. Reading Text from a File


[Visual Basic, C#, C++] This code example is part of a larger example provided for the System.IO.StringWriter.StringWriter constructor.

[Visual Basic] 
Console.WriteLine("The following string is {0} encoded." _
    & vbCrLf & "{1}", _
    strWriter.Encoding.EncodingName, strWriter.ToString())

Console.WriteLine("The following string is {0} encoded.\n{1}", 
    strWriter.Encoding.EncodingName, strWriter.ToString());

Console::WriteLine(S"The following string is {0} encoded.\n{1}",
    strWriter->Encoding->EncodingName, strWriter->ToString());

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

StringWriter Class | StringWriter Members | System.IO Namespace | Working with I/O | Reading Text from a File | Writing Text to a File

© 2017 Microsoft