I just want to be sure:
string x = "";
char Char = x[0]; // throws exception: "Index was outside the bounds of the array"
This means that the string is really treated as an array of chars, right? (At least internally.)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Per @JaredPar elsewhere on this site:
I am sure you should not rely on this as it’s not part of the interface, but implementation is an array if this statement is correct. That makes sense to me given what we know about char-strings and Microsoft’s need to support efficient interop between managed and native languages.
MSDN says only this, which does not guarantee that the storage is an array.