What is the difference in usage and implementation between System::String and Std::String in CPP CLR?

Std::String is the CPP standard library string type, System::String is the type in CLR CPP, and System::String can be used in both C-sharp and CLR CPP programs.

The benefits of

Std::String are obvious. It is part of the standard CPP, and other systems such as Linux can also use Std::String.

but if my program only needs to run on Windows, not on other systems such as Linux, should I use System::String or Std::String?

in theory, since Microsoft has created a System::String in addition to Std, this string type should also have its advantages over standard String. What are the advantages? Apart from the fact that C-sharp can also be used, is there any practical advantage over Std::String?

Jun.27,2022

are two different things at all.
System::String is a managed class, resources are in the managed heap, and functionality is provided by CLR.
std::string is a local class, resources are in the local heap, and functionality is provided by CPP runtime.
it's not that Microsoft has created its own class outside std. Microsoft does CPP/CLI to connect. Net and CPP, so things in both places can be used. However, the two can not be replaced directly, and they need to be converted to each other.

as for your saying that no matter which linux platform you should use, CPP/CLI is still exclusive to windows, even if you want to use it on linux.

finally you said that there was a compilation error because your writing didn't work in CPP. Include header files are required in CPP.

suggestion: don't get involved in the muddy waters of CPP/CLI if you haven't studied CPP.


Microsoft also encapsulated some high-level objects such as CString in MFC, and the advantage is that it is more suitable for the working environment of MFC. Such encapsulation is more ready-made algorithms such as Qt and QString, which can simplify the code by split and join. The standard library, like its name, works in a platform-independent environment and can be used for windows,linux,macOS. C-sharp and CLI cPP are Microsoft libraries based on Windows.

1. The practical benefit is that it encapsulates more off-the-shelf methods for dealing with strings.
2. You do not need to declare a scope after using a namespace.
3. The < operator is used to write to the output stream.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e784f4-5b4e1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e784f4-5b4e1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?