Is string actually an array of chars or does it just have an indexer?

System.String is not a .NET array of Char because this:

char[] testArray = "test".ToCharArray();

testArray[0] = 'T';

will compile, but this:

string testString = "test";

testString[0] = 'T';

will not. Char arrays are mutable, Strings are not. Also, string is Array returns false, while char[] is Array returns true.

Leave a Comment