TextReader.ReadBlock TextReader.ReadBlock TextReader.ReadBlock TextReader.ReadBlock Method

定義

多載

ReadBlock(Span<Char>) ReadBlock(Span<Char>) ReadBlock(Span<Char>) ReadBlock(Span<Char>)
ReadBlock(Char[], Int32, Int32) ReadBlock(Char[], Int32, Int32) ReadBlock(Char[], Int32, Int32) ReadBlock(Char[], Int32, Int32)

從目前的文字讀取器讀取指定的最大字元數目,並從指定的索引開始將資料寫入緩衝區。Reads a specified maximum number of characters from the current text reader and writes the data to a buffer, beginning at the specified index.

ReadBlock(Span<Char>) ReadBlock(Span<Char>) ReadBlock(Span<Char>) ReadBlock(Span<Char>)

public:
 virtual int ReadBlock(Span<char> buffer);
public virtual int ReadBlock (Span<char> buffer);
abstract member ReadBlock : Span<char> -> int
override this.ReadBlock : Span<char> -> int
Public Overridable Function ReadBlock (buffer As Span(Of Char)) As Integer

參數

buffer
Span<Char>

傳回

ReadBlock(Char[], Int32, Int32) ReadBlock(Char[], Int32, Int32) ReadBlock(Char[], Int32, Int32) ReadBlock(Char[], Int32, Int32)

從目前的文字讀取器讀取指定的最大字元數目,並從指定的索引開始將資料寫入緩衝區。Reads a specified maximum number of characters from the current text reader and writes the data to a buffer, beginning at the specified index.

public:
 virtual int ReadBlock(cli::array <char> ^ buffer, int index, int count);
public virtual int ReadBlock (char[] buffer, int index, int count);
abstract member ReadBlock : char[] * int * int -> int
override this.ReadBlock : char[] * int * int -> int
Public Overridable Function ReadBlock (buffer As Char(), index As Integer, count As Integer) As Integer

參數

buffer
Char[]

當這個方法傳回時,這個參數會包含指定的字元陣列,這個陣列具有介於 index 到 (index + count -1) 之間的值,已由讀取自目前來源的字元所取代。When this method returns, this parameter contains the specified character array with the values between index and (index + count -1) replaced by the characters read from the current source.

index
Int32 Int32 Int32 Int32

buffer 中要開始寫入的位置。The position in buffer at which to begin writing.

count
Int32 Int32 Int32 Int32

要讀取的字元數上限。The maximum number of characters to read.

傳回

已經讀取的字元數目。The number of characters that have been read. 數目將小於或等於 count,取決於是否已經讀取所有輸入字元。The number will be less than or equal to count, depending on whether all input characters have been read.

例外狀況

緩衝區長度減去 index 會小於 countThe buffer length minus index is less than count.

發生 I/O 錯誤。An I/O error occurs.

備註

基礎的文字讀取器的位置進階的字元數目,顯示已讀入至bufferThe position of the underlying text reader is advanced by the number of characters that were read into buffer.

方法會封鎖直到count會讀取的字元,或已經讀取所有字元。The method blocks until either count characters are read, or all characters have been read. 這是封鎖版本ReadThis is a blocking version of Read.

另請參閱

適用於