The String

The .NET framework has extensive support for strings. The System namespace has a System.String class that can be used to store text.

The managed extensions to C++ also allow you to use the System.String object through the String extension.

You can define a string under managed C++ as follows:

String *pS=S"Hello World";

These strings are created on the Garbage Collected heap and are subject to lifetime management.

Notice the S prefix to the string literal. All instances of identical strings prefixed by S are essentially the same string. A string literal can also be prefixed with L. This signifies that it is a wide character string:

String *s=L"This is a wide string";

Each string is immutable. Once you've made it you can't change ...

Get C# and the .NET Framework: The C++ Perspective now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.