I have this code which output some value from array, plus -
in new line under value a[i]
Console.Write(a[i] + "\n-");
So it looks like this
a
-
Now i have more of Console.Write(a[i+1] + "\n-");
codes and it outputs like this
a
-b
-c
-d
-
I know why this is the case but how can I return one line up after every new line \n
? So I can get this
abcd
----
You have to output the values first, then the dashes:
Console.WriteLine(string.Join("", a)); // make a string of all values and write a line end
Console.WriteLine(string.Join("", a.Select(v => "-"))); // write the dashes
[Ideone]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With