String::Length Method

Retrieves the number of characters in the current String object.

    unsigned int Length()

The number of characters in the current String object.

The length of a String with no characters is zero. The length of the following string is 5:

String^ str = "Hello";
int len = str->Length(); //len = 5

The character array returned by the String::Data Method has one additional character, which is the terminating NULL or ‘\0’. This character is also two bytes long.

Minimum supported client: Windows 8

Minimum supported server: Windows Server 2012

Namespace: Platform

Metadata: vccorlib.h

Show:
© 2014 Microsoft