Asynchronously writes a subarray of characters to the stream, followed by a line terminator.
public:
override System::Threading::Tasks::Task ^ WriteLineAsync(cli::array <char> ^ buffer, int index, int count);
public override System.Threading.Tasks.Task WriteLineAsync(char[] buffer, int index, int count);
[System.Runtime.InteropServices.ComVisible(false)]
public override System.Threading.Tasks.Task WriteLineAsync(char[] buffer, int index, int count);
override this.WriteLineAsync : char[] * int * int -> System.Threading.Tasks.Task
[<System.Runtime.InteropServices.ComVisible(false)>]
override this.WriteLineAsync : char[] * int * int -> System.Threading.Tasks.Task
Public Overrides Function WriteLineAsync (buffer As Char(), index As Integer, count As Integer) As Task
Parameters
The character array to write data from.
The character position in the buffer at which to start reading data.
The maximum number of characters to write.
ReturnsA task that represents the asynchronous write operation.
The index
plus count
is greater than the buffer length.
index
or count
is negative.
The stream writer is disposed.
The stream writer is currently in use by a previous write operation.
ExamplesThe following example shows how to write characters to two separate lines in a text file by using the WriteLineAsync(Char[], Int32, Int32) method. The first line contains the first 11 characters from the string (the letters "First line" followed by a space). The second line contains the remaining characters from the string (the letters "and second line").
using System.IO;
using System.Text;
namespace ConsoleApplication
{
class Program6
{
static void Main()
{
WriteCharacters();
}
static async void WriteCharacters()
{
UnicodeEncoding ue = new UnicodeEncoding();
char[] charsToAdd = ue.GetChars(ue.GetBytes("First line and second line"));
using (StreamWriter writer = File.CreateText("newfile.txt"))
{
await writer.WriteLineAsync(charsToAdd, 0, 11);
await writer.WriteLineAsync(charsToAdd, 11, charsToAdd.Length - 11);
}
}
}
}
Imports System.IO
Imports System.Text
Module Module1
Sub Main()
WriteCharacters()
End Sub
Async Sub WriteCharacters()
Dim ue As UnicodeEncoding = New UnicodeEncoding()
Dim charsToAdd() = ue.GetChars(ue.GetBytes("First line and second line"))
Using writer As StreamWriter = File.CreateText("newfile.txt")
Await writer.WriteLineAsync(charsToAdd, 0, 11)
Await writer.WriteLineAsync(charsToAdd, 11, charsToAdd.Length - 11)
End Using
End Sub
End Module
Remarks
The line terminator is defined by the TextWriter.NewLine property.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4