2
    public void Dashes()
    {
        for (int i = 0; i < SelectedWord.Length; i++)
            console.WriteLine("_");

    }

this is the only thing i can think of and whenever I go to run it puts it on all separate lines when I want it on 1 line

kravits88
  • 12,431
  • 1
  • 51
  • 53
Ryan Van Dusen
  • 101
  • 3
  • 10

4 Answers4

2
public void Dashes()
{
    for (int i = 0; i < SelectedWord.Length; i++)
        console.Write("_");

}

Thanks to @Grant Winney

Ryan Van Dusen
  • 101
  • 3
  • 10
0

Try this

            string output = "";
            for (int i = 0; i < SelectedWord.Length; i++)
            {
                output += "_";
            }
            console.WriteLine(output);
jdweng
  • 33,250
  • 2
  • 15
  • 20
0

The console,writeline prints starts a new line everytime its called in your loop.

public void Dashes()
    {
        string dashes ="";
        for (int i = 0; i < SelectedWord.Length; i++)
            dashes +="_";
        console.WriteLine(dashes);

    }
user3621898
  • 589
  • 5
  • 24
  • Why not just simply use Console.Write instead of Console.WriteLine and save all the immutable concatenation? – Cubicle.Jockey Dec 05 '15 at 02:40
  • You would still need a writeline(). The person asking this question is a novice and don't make things more complicated than necessary. – jdweng Dec 05 '15 at 06:15
0

You can also ditch the loop entirely if running .NET 4 or above and use the following single line (as per this answer):

console.WriteLine(String.Concat(Enumerable.Repeat("_", SelectedWord.Length)));
Community
  • 1
  • 1
MTCoster
  • 5,868
  • 3
  • 28
  • 49