Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i read a string one one character?
Posted
Updated 19-Oct-10 23:15pm
v2

Use indexer from the string.
C#
string str = "Welcome";
char i = str[3];

i will hold 'c'.
 
Share this answer
 
v2
Console.ReadLine();
 
Share this answer
 
Comments
Dalek Dave 20-Oct-10 5:35am    
Funny!
C#
string str = "example"
for (int i = 0; i < str.Length; i++)
{
  MessageBox.Show(str[i].ToString());
}
 
Share this answer
 
v2
The Question is ambiguous.

What is the context you are requiring this function for?

What do you mean by 'read a string one one character'?

More Information required, ok.
 
Share this answer
 
C#
string str = "Hello";
            string nStr = string.Empty;
            foreach (char c in str)
            {
                nStr += c.ToString();//Code Here
            }
            MessageBox.Show(nStr);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900