description | title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: How to: Write characters to a string |
How to: Write characters to a string |
01/21/2019 |
|
|
1222cbeb-0760-44bf-9888-914a2a37174b |
The following code examples write characters synchronously or asynchronously from a character array into a string.
The following example uses a xref:System.IO.StringWriter to write five characters synchronously to a xref:System.Text.StringBuilder object.
[!code-csharpConceptual.StringBuilder#9] [!code-vbConceptual.StringBuilder#9]
The next example is the code behind a WPF app. On window load, the example asynchronously reads all characters from a xref:System.Windows.Controls.TextBox control and stores them in an array. It then asynchronously writes each letter or white-space character to a separate line of a xref:System.Windows.Controls.TextBlock control.
[!code-csharpStreamReaderWriter] [!code-vbStreamReaderWriter]
- xref:System.IO.StringWriter
- xref:System.IO.StringWriter.Write%2A?displayProperty=nameWithType
- xref:System.Text.StringBuilder
- File and stream I/O
- Asynchronous file I/O
- How to: Enumerate directories and files
- How to: Read and write to a newly created data file
- How to: Open and append to a log file
- How to: Read text from a file
- How to: Write text to a file
- How to: Read characters from a string