string value = "test";
for (int i = 0; i < value.Length; i++)
{
Console.WriteLine(value[i]);
}
output of the program is:
t
e
s
t
I want the output would be "test"
string value = "test";
for (int i = 0; i < value.Length; i++)
{
Console.WriteLine(value[i]);
}
output of the program is:
t
e
s
t
I want the output would be "test"
Use Console.Write()
string value = "test";
for (int i = 0; i < value.Length; i++)
{
Console.Write(value[i]);
}
The reason as to why your output is printing on a different line is because of Console.WriteLine
..
That needs to be changed to Console.Write
so the in the body of your for loop:
Console.Write(value[i]);
Maybe use Char Array instead of String, if you want to concentrate on each character.
But I would like to join my previous speakers to use
Console.Write(value);
Please keep in mind, that your string has already the value test and there is no need to iterate through each char.