StreamReader.ReadBlock StreamReader.ReadBlock StreamReader.ReadBlock StreamReader.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 stream 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:
 override int ReadBlock(Span<char> buffer);
public override int ReadBlock (Span<char> buffer);
override this.ReadBlock : Span<char> -> int
Public Overrides 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 stream and writes the data to a buffer, beginning at the specified index.

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

參數

buffer
Char[]

當這個方法傳回時,會包含指定的字元陣列,這個陣列具有介於 index 到 (index + count - 1) 之間的值,已由讀取自目前來源的字元所取代。When this method returns, 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 occurred.

備註

基礎資料流程的位置會依讀入buffer的字元數來前移。The position of the underlying stream is advanced by the number of characters that were read into buffer.

方法會封鎖,直到count讀取任一字元,或已到達資料流程的結尾為止。The method blocks until either count characters are read, or the end of the stream has been reached. 這是的封鎖版本ReadThis is a blocking version of Read.

適用於