Windows apps
Collapse the table of content
Expand the table of content
Information
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.ToString Method

Returns a string containing the characters written to the current StringWriter so far.

[Visual Basic]
Overrides Public Function ToString() As String
[C#]
public override string ToString();
[C++]
public: String* ToString();
[JScript]
public override function ToString() : String;

Return Value

The string containing the characters written to the current StringWriter.

Remarks

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

Example

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

[Visual Basic] 
Console.WriteLine( _
    "Current date and time using the invariant culture: {0}" _
    & vbCrLf & _
    "Current date and time using the Algerian culture: {1}", _
    DateTime.Now.ToString(), strWriter.ToString())

[C#] 
Console.WriteLine(
    "Current date and time using the invariant culture: {0}\n" +
    "Current date and time using the Algerian culture: {1}", 
    DateTime.Now.ToString(), strWriter.ToString());

[C++] 
Console::WriteLine(
    S"Current date and time using the invariant culture: {0}\n"
    S"Current date and time using the Algerian culture: {1}", 
    DateTime::Now.ToString(), 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.

Requirements

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

Show:
© 2016 Microsoft