I recently tried to do the following in C #
string str = "u r awesome"; str[0]="i";
And this will not work, because, apparently, str [i] is just not a collection, so I was wondering if the main implementation of the string is to make str [i] only be get.
Isn't that just a managed shell for char *? So why can't I set str [i]?
The answers others have given regarding immutability are, of course, correct and are the "actual" cause of the problem you have.
(, ), , , :
" .NET CLR BSTR OLE Automation: , , , UTF-16, ."
" " , BSTR .
, . , , .
, .NET String - , . , , , .
String
, , StringBuilder.
StringBuilder
C, String const char *, , . StringBuilder char * ( ) (ToString()) String .
const char *
char *
ToString()
cdhowie, , c/++
, ,
List<char> str = new List<char>("u r awesome"); str[0] = 'i'; str[2] = 'm'; Console.WriteLine(str.ToArray());