Reputation: 48086
In answering another question someone pointed out that in C# you can access a character in string by doing sting[i]. My question is, what is happening under the covers? Is this any different than converting the string to a character array and then parsing it?
I assume the difference is in memory usage and mutability but I'd rather know than assume :)
Upvotes: 3
Views: 224
Reputation: 124696
The main difference is that converting to a character array will create a copy of the string's internal character array, whereas using the indexer will access the characters in place.
Upvotes: 6