A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://learn.microsoft.com/en-us/dotnet/api/system.io.streamwriter.write below:

StreamWriter.Write Method (System.IO) | Microsoft Learn

Source:
StreamWriter.cs
Source:
StreamWriter.cs
Source:
StreamWriter.cs
Source:
StreamWriter.cs

Writes a subarray of characters to the stream.

public:
 override void Write(cli::array <char> ^ buffer, int index, int count);
public override void Write(char[] buffer, int index, int count);
override this.Write : char[] * int * int -> unit
Public Overrides Sub Write (buffer As Char(), index As Integer, count As Integer)
Parameters
buffer
Char[]

A character array that contains the data to write.

index
Int32

The character position in the buffer at which to start reading data.

count
Int32

The maximum number of characters to write.

Exceptions

The buffer length minus index is less than count.

index or count is negative.

AutoFlush is true or the StreamWriter buffer is full, and the contents of the buffer cannot be written to the underlying fixed size stream because the StreamWriter is at the end the stream.

Examples

This example writes eight characters from a 13-element array to a file, beginning at the third element of the array.

using System;
using System.IO;

public class SWBuff
{
    public static void Main(String[] args)
    {
        FileStream sb = new FileStream("MyFile.txt", FileMode.OpenOrCreate);
        char[] b = {'a','b','c','d','e','f','g','h','i','j','k','l','m'};
        StreamWriter sw = new StreamWriter(sb);
        sw.Write(b, 3, 8);
        sw.Close();
    }
}
Imports System.IO

Public Class SWBuff

    Public Shared Sub Main()
        Dim sb As New FileStream("MyFile.txt", FileMode.OpenOrCreate)
        Dim b As Char() = {"a"c, "b"c, "c"c, "d"c, "e"c, "f"c, "g"c, _
           "h"c, "i"c, "j"c, "k"c, "l"c, "m"c}
        Dim sw As New StreamWriter(sb)
        sw.Write(b, 3, 8)
        sw.Close()
    End Sub
End Class
Remarks

This method overrides TextWriter.Write.

The characters are read from buffer beginning at index and continuing through index + (count - 1). All characters are written to the underlying stream unless the end of the underlying stream is reached prematurely. Flush is invoked automatically if AutoFlush is true.

For a list of common I/O tasks, see Common I/O Tasks.

See also

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