{{fbdoc item="title" value="Operator [] (String index)"}}----
Returns a reference to the numeric value of a character in a string

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **[]** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] [[KeyPgString|string]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgByrefFunction|byref]] [[KeyPgAs|as]] [[KeyPgUbyte|ubyte]]
	[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **[]** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] [[KeyPgZstring|zstring]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgByrefFunction|byref]] [[KeyPgAs|as]] [[KeyPgUbyte|ubyte]]
	[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **[]** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] [[KeyPgWstring|wstring]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgByrefFunction|byref]] [[KeyPgAs|as]] //T//
##
{{fbdoc item="usage"}}##
		//result// = //lhs// **[** //rhs// **]**
	or
		//lhs// **[** //rhs// **]** = //value//
##
{{fbdoc item="param"}}
	##//lhs//##
		The string (a string reference, not a string returned as local copy).
	##//rhs//##
		A zero-based offset from the first character.
	##//T//##
		The wide-character type (varies per platform).

{{fbdoc item="desc"}}
	This operator returns a reference to the numeric value of a specific character in a string:
		- For a ##[[KeyPgString|String]]## or a ##[[KeyPgZstring|ZString]]##:
				a ##[[KeyPgUbyte|Ubyte]]## (containing the ASCII value of the character).
		- For a ##[[KeyPgWstring|WString]]##:
				a numeric type depending on platform, for example ##[[KeyPgUshort|UShort]]## for Windows or ##[[KeyPgUlong|ULong]]## for Linux (containing the numeric value of the character).
				
	This operator must not be used in case of empty string because reference is undefined (inducing runtime error).
	Otherwise, the user must ensure that the index does not exceed the range "[0, ##[[KeyPgLen|Len]](//lhs//) - 1##]". Outside this range, results are undefined.
	
	Unlike 'return by value' (where only a copy is returned), 'return by reference' allows you to also modify the referenced variable.
	'Return by reference' is implemented under the hood as a pointer implicitly dereferenced:
		**""-""** In case of a ##[[KeyPgString|String]]## or a ##[[KeyPgZstring|ZString]]## ##'s'##:
			##s[n]## is equivalent to ##[[KeyPgOpValueOf|*]][[KeyPgCptr|Cptr]](Ubyte [[KeyPgPtr|Ptr]], [[KeyPgOpStrptr|Strptr]](s) + n)##
		**""-""** In case of a ##[[KeyPgWstring|WString]]## ##'s'##:
			##s[n]## is equivalent to ##[[KeyPgOpValueOf|*]][[KeyPgCptr|Cptr]](T [[KeyPgPtr|Ptr]], [[KeyPgOpStrptr|Strptr]](s) + n)##
			
	**Note:** The fact that this operator returns a reference greatly differentiates it from ##[[KeyPgAsc|Asc]]( str [, position ] )## which allows to return the numeric representation of a character, but not to modify it.

{{fbdoc item="ex"}}
	{{fbdoc item="filename" value="examples/manual/operator/stringindex.bas"}}%%(freebasic)
Dim a As String = "Hello, world!"
Dim i As Integer

For i = 0 To Len(a) - 1
	Print Chr(a[i]) & " ";
Next i
Print
Print

For i = 1 To 4
	a[i] = a[i] - 32  ' converting lowercase alphabetic characters to uppercase
Next i
For i = 7 To 11
	a[i] = a[i] - 32  ' converting lowercase alphabetic characters to uppercase
Next i
Print a
	%%Will print:
		%%
H e l l o ,   w o r l d !

HELLO, WORLD!
		%%
{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- [[CatPgOpString|String Operators]]

{{fbdoc item="back" value="CatPgOpIndexing|Indexing Operators"}}{{fbdoc item="back" value="CatPgOperators|Operators"}}