Strings.GetChar(String, Int32) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a Char
value representing the character from the specified index in the supplied string.
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
- str
- String
Required. Any valid String
expression.
- Index
- Int32
Required. Integer
expression. The (1-based) index of the character in str
to be returned.
Char
value representing the character from the specified index in the supplied string.
str
is Nothing
, Index
< 1, or Index
is greater than index of last character of str
.
This example shows how to use the GetChar
function to return a character from a specified index in a String
.
Dim testString As String = "ABCDE"
Dim testChar As Char
' Returns "D"
testChar = GetChar(testString, 4)
If Index
is less than 1 or greater than the index of the last character in str
, an ArgumentException
is thrown.
Product | Versies |
---|---|
.NET | Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Feedback over .NET
.NET is een opensourceproject. Selecteer een koppeling om feedback te geven: