Is the string actually a character array (is-a) or has an array of characters as internal storage (has-a), or is it a native object that can expose itself as a with an array of characters?
I am more inclined to say that this is our own object, but then why are we so inclined to always say: "A string is an array of characters ..."?
The .NET string is not just an array of characters. It contains an array of characters, so strictly speaking, it has-a.
, , Unicode, . , . Unicode . , , - .
"".
System.String .NET ( (, O (1)), ).
System.String
- , :))
, , string " ", " char[]". "" -.:))
string
char[]
- .
.Net String (has-a) , .
: " Apple ? , ".
MSDN: .
: Unicode.
(, , ) - .
, , .
String - . . unicode ASCII , , . , , . .
. (ascii char * string) , int, ascii, (char (0)). , , , char * .
, . GCHandle, , , , 32- , Unicode ( , AddrOppinedObject , . , P/Invoking).
. (, C), . , .
However, for other purposes, saving Unicode strings as UTF-8 may be the most appropriate form. Note that although it is stored in a byte array, there is no longer a one-to-one correspondence between bytes and characters: your string algorithms should usually access characters sequentially from the very beginning - in the form of a list.
The moral of this story is: your string code should only require random access, if you really need it. You may be surprised how rarely you really need an array of characters.