SqlDataReader.GetBytes(Int32, Int64, Byte[], Int32, Int32) 方法

定義

從指定資料行位移將位元組資料流讀取到緩衝區中,作為以指定的緩衝區位移開頭的陣列。

public:
 override long GetBytes(int i, long dataIndex, cli::array <System::Byte> ^ buffer, int bufferIndex, int length);
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, byte[] buffer, int bufferIndex, int length);
public long GetBytes (int i, long dataIndex, byte[] buffer, int bufferIndex, int length);
override this.GetBytes : int * int64 * byte[] * int * int -> int64
abstract member GetBytes : int * int64 * byte[] * int * int -> int64
override this.GetBytes : int * int64 * byte[] * int * int -> int64
Public Overrides Function GetBytes (i As Integer, dataIndex As Long, buffer As Byte(), bufferIndex As Integer, length As Integer) As Long
Public 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 正在將大型數據結構讀取到緩衝區,則可能是這種情況。 如需詳細資訊,請參閱 SequentialAccessCommandBehavior設定。

如果您傳遞的緩衝區為 nullGetBytes 則會以位元組為單位傳回整個欄位的長度,而不是根據緩衝區位移參數的剩餘大小。

不會執行任何轉換;因此,擷取的數據必須是位元組陣列。

適用於

另請參閱