SqlDataReader.GetChars(Int32, Int64, Char[], Int32, Int32) Metodo

Definizione

Legge un flusso di caratteri dall'offset di colonna specificato nel buffer sotto forma di matrice, a partire dall'offset di buffer specificato.

public:
 override long GetChars(int i, long dataIndex, cli::array <char> ^ buffer, int bufferIndex, int length);
public:
 virtual long GetChars(int i, long dataIndex, cli::array <char> ^ buffer, int bufferIndex, int length);
public override long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length);
public long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length);
override this.GetChars : int * int64 * char[] * int * int -> int64
abstract member GetChars : int * int64 * char[] * int * int -> int64
override this.GetChars : int * int64 * char[] * int * int -> int64
Public Overrides Function GetChars (i As Integer, dataIndex As Long, buffer As Char(), bufferIndex As Integer, length As Integer) As Long
Public Function GetChars (i As Integer, dataIndex As Long, buffer As Char(), bufferIndex As Integer, length As Integer) As Long

Parametri

i
Int32

Ordinale di colonna in base zero.

dataIndex
Int64

Indice nel campo da cui iniziare l'operazione di lettura.

buffer
Char[]

Buffer in cui leggere il flusso di byte.

bufferIndex
Int32

Indice all'interno del parametro buffer dal quale iniziare l'operazione di scrittura.

length
Int32

Lunghezza massima per la copia nel buffer.

Restituisce

Numero effettivo di caratteri letti.

Implementazioni

Commenti

GetChars restituisce il numero di caratteri disponibili nel campo. Spesso si tratta della lunghezza esatta del campo. Tuttavia, il numero restituito può essere minore della lunghezza effettiva del campo se è già stato usato il metodo GetChars per ottenere i caratteri del campo. Questo può essere il caso, ad esempio, se si SqlDataReader legge una struttura di dati di grandi dimensioni in un buffer. Per altre informazioni, vedere l'impostazione SequentialAccess per CommandBehavior.

Il numero effettivo di caratteri letti può essere minore della lunghezza richiesta, se viene raggiunta la fine del campo. Se si passa un buffer che è null, GetChars restituisce la lunghezza dell'intero campo in caratteri, non le dimensioni rimanenti in base al parametro di offset del buffer.

Non vengono eseguite conversioni; Quindi. i dati recuperati devono essere già una matrice di caratteri.

Nota

Il GetChars metodo restituisce 0 quando dataIndex è negativo.

Si applica a

Vedi anche