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
  • 11,611
  • 1
  • 49
  • 52
Ryan Van Dusen
  • 101
  • 1
  • 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
  • 1
  • 10
0

Try this

            string output = "";
            for (int i = 0; i < SelectedWord.Length; i++)
            {
                output += "_";
            }
            console.WriteLine(output);
jdweng
  • 29,955
  • 2
  • 14
  • 18
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
  • 560
  • 4
  • 22
  • 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,621
  • 3
  • 29
  • 48