SqlDataReader.GetBytes(Int32, Int64, Byte[], Int32, Int32) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将指定列偏移量的字节流读取到从给定缓冲区偏移量开始的数组的缓冲区中。
public:
virtual long GetBytes(int i, long dataIndex, cli::array <System::Byte> ^ buffer, int bufferIndex, int length);
public:
override long GetBytes(int i, long dataIndex, cli::array <System::Byte> ^ buffer, int bufferIndex, int length);
public long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length);
public override long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length);
abstract member GetBytes : int * int64 * byte[] * int * int -> int64
override this.GetBytes : int * int64 * byte[] * int * int -> int64
override this.GetBytes : int * int64 * byte[] * int * int -> int64
Public Function GetBytes (i As Integer, dataIndex As Long, buffer As Byte(), bufferIndex As Integer, length As Integer) As Long
Public Overrides Function GetBytes (i As Integer, dataIndex As Long, buffer As Byte(), bufferIndex As Integer, length As Integer) As Long
参数
- i
- Int32
从零开始的列序号。
- dataIndex
- Int64
从中开始读取操作的字段中的索引。
- buffer
- Byte[]
要在其中读取字节流的缓冲区。
- bufferIndex
- Int32
写入操作开始的位置内的 buffer 索引。
- length
- Int32
要复制到缓冲区的最大长度。
返回
读取的实际字节数。
实现
注解
GetBytes 返回字段中的可用字节数。 大多数情况下,这是字段的确切长度。 但是,如果 GetBytes 已用于从字段中获取字节,则返回的数字可能小于字段的真实长度。 例如,如果 SqlDataReader 正在将大型数据结构读取到缓冲区中,则可能是这种情况。 有关详细信息,请参阅设置SequentialAccess。CommandBehavior
如果传递缓冲区,nullGetBytes则返回整个字段的长度(以字节为单位,而不是基于缓冲区偏移参数的剩余大小)。
不执行任何转换;因此,检索的数据必须是字节数组。