CString::operator [ ]

TCHARoperator[](intnIndex**)const;**

Parameters

nIndex

Zero-based index of a character in the string.

Remarks

You can think of a CString object as an array of characters. The overloaded subscript ([]) operator returns a single character specified by the zero-based index in nIndex. This operator is a convenient substitute for the GetAt member function.

Important   You can use the subscript ([]) operator to get the value of a character in a CString, but you cannot use it to change the value of a character in a CString.

Example

The following example demonstrates the use of CString::operator [ ].

// example for CString::operator [ ]
CString s( "abc" );
ASSERT( s[1] == 'b' );

CString OverviewClass MembersHierarchy Chart

See Also   CString::GetAt, CString::SetAt