Szerkesztés

Megosztás a következőn keresztül:


StringWriter.Encoding Property

Definition

Gets the Encoding in which the output is written.

public:
 virtual property System::Text::Encoding ^ Encoding { System::Text::Encoding ^ get(); };
public override System.Text.Encoding Encoding { get; }
member this.Encoding : System.Text.Encoding
Public Overrides ReadOnly Property Encoding As Encoding

Property Value

The Encoding in which the output is written.

Examples

This code example is part of a larger example provided for the StringWriter() constructor.

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

Remarks

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. How to: Write Text to a File
Write to a text file. How to: Write Text to a File
Read from a text file. How to: Read Text from a File

Applies to

See also