Strings.GetChar(String, Int32) Metodo

Definizione

Restituisce un Char valore che rappresenta il carattere dell'indice specificato nella stringa specificata.

public:
 static char GetChar(System::String ^ str, int Index);
public static char GetChar(string str, int Index);
static member GetChar : string * int -> char
Public Function GetChar (str As String, Index As Integer) As Char

Parametri

str
String

Required. Qualsiasi espressione valida String .

Index
Int32

Required. Integer espressione. Indice (in base 1) del carattere in str da restituire.

Valori restituiti

Char valore che rappresenta il carattere dell'indice specificato nella stringa specificata.

Eccezioni

str è Nothing, Index< 1 o Index è maggiore dell'indice dell'ultimo carattere di str.

Esempio

In questo esempio viene illustrato come usare la GetChar funzione per restituire un carattere da un indice specificato in un oggetto String.

Dim testString As String = "ABCDE"
Dim testChar As Char
' Returns "D"
testChar = GetChar(testString, 4)

Commenti

Se Index è minore di 1 o maggiore dell'indice dell'ultimo carattere in str, viene generata un'eccezione ArgumentException .

Si applica a

Vedi anche