System.IO.TextReader.ReadBlock 方法

方法描述

从当前流中读取最大 count 的字符并从 index 开始将该数据写入 buffer。

语法定义(C# System.IO.TextReader.ReadBlock 方法 的用法)

public virtual int ReadBlock(
	char[] buffer,
	int index,
	int count
)

参数/返回值

参数值/返回值 参数类型/返回类型 参数描述/返回描述
buffer System-Char[] 此方法返回时,此参数包含指定的字符数组,该数组中从 index 到 (index + count -1) 之间的值由从当前源中读取的字符替换。
index System-Int32 在 buffer 中开始写入的位置。
count System-Int32 最多读取的字符数。
返回值 System.Int32 基础流的位置由读入 buffer 的字符编号提前。 已读取的字符数。 该数字将小于或等于 count,具体取决于是否所有的输入字符都已读取。

提示和注释

此方法将阻塞,直到读取数目为 count 的字符或读取了所有字符。 这是 Read 的条块化版本。

System.IO.TextReader.ReadBlock 方法例子


异常

异常 异常描述
ArgumentNullException buffer 为 null。
ArgumentException 缓冲区长度减去 index 小于 count。
ArgumentOutOfRangeException index 或 count 为负。
ObjectDisposedException TextReader 是关闭的。
IOException 发生 I/O 错误。

命名空间

namespace: System.IO

程序集: mscorlib(在 mscorlib.dll 中)

版本信息

.NET Framework 受以下版本支持:4、3.5、3.0、2.0、1.1、1.0 .NET Framework Client Profile 受以下版本支持:4、3.5 SP1 受以下版本支持:

适用平台

Windows 7, Windows Vista SP1 或更高版本, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008(不支持服务器核心), Windows Server 2008 R2(支持 SP1 或更高版本的服务器核心), Windows Server 2003 SP2 .NET Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。