Reputation: 767
Why do they have a System::String
and a std::string
in c++?
I couldn't find anything about this, except some topics about converting the one to another.
I noticed this when I want to put information of a textbox
into a std::string
variable. so I had to do some odd converting to get this.
Why do they have these 2 different strings when they actually do the same for coding? (holding a string value).
Upvotes: 4
Views: 2115
Reputation: 29966
std::string
is a class template from the c++ standard library that stores and manipulates strings. The data in std::string
is basically a sequence of bytes, i.e. it doesn't have en encoding. std::string
supports the most basic set of operations that you would expect from a string, namely it gives you methods for substring search and replace.
System::string
is a class from Microsoft's .Net framework. It represents text as a series of Unicode characters, and has some more specialized methods like StartsWith
, EndsWith
, Split
, Trim
, ans so on.
Upvotes: 4