|
-
March 24th, 2009, 09:47 AM
#1
String Manipulation query
Hi,
I am having difficulty understand the second line of the code below:
Code:
string myString = "A string";
char myChar = myString[1];
The first line is creating and declaring a string, but I am not sure about the second line. The book I am following is using this code as an example. The book says "Its worth noting that a string type variable can be treated as a read only array of char variables. This means that you can access individual characters using syntax like in the code above.
Although its a simple explanation I still dont understand it. What is the code trying to do and what is the ' [1]' doing at the end of myString?
Thanks in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|