SqlDataReader.GetBytes(Int32, Int64, Byte[], Int32, Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從指定的欄位偏移量讀取一串位元組到緩衝區,該陣列從指定緩衝區偏移開始。
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 大型資料結構讀取到緩衝區時,情況可能就會出現。 欲了解更多資訊,請參閱 的SequentialAccess設定。CommandBehavior
如果你傳遞一個緩衝區,也就是 null, GetBytes 會回傳整個欄位的長度(以位元組為單位),而不是根據緩衝區偏移參數計算的剩餘大小。
不進行任何轉換;因此,檢索的資料必須已經是位元組陣列。