-1

How do I arrange the numbers next to each other instead of on top of each other?

I tried implementing \t but it gives me an error or doesn't do anything at all.

 int[] anzFeldElemente = new int[10];
        Random wuerfel = new Random();

        for (int i = 0; i < anzFeldElemente.Length; i++)
        {
            anzFeldElemente[i] = wuerfel.Next(0, 100);
        }

        Array.Sort(anzFeldElemente);

        foreach (int i in anzFeldElemente)
        {
            Console.WriteLine(i "\t");
        }

        Console.ReadLine();

Also, is it possible to draw a field similar to Microsoft Excel in a console app? Is there a function to draw one?

Thanks in advance.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Bradolf
  • 35
  • 1
  • 2
  • 10

3 Answers3

2

Using Console.WriteLine will force it to move to the next line every time you iterate. As recommended by lazyberezovsky use the Console.Write instead. Remember to include a white space to divide up the elements using +", "

tommy knocker
  • 371
  • 1
  • 7
  • 19
0

As the name implies, Console.WriteLine writes a line.

Instead of

Console.WriteLine(i "\t");

Try

Console.Write(i + "\t"); 

Or

Console.Write("{0}\t", i); 
Rik
  • 28,507
  • 14
  • 48
  • 67
0

It should be like this:

Console.Write(i + "\t");
Tobberoth
  • 9,327
  • 2
  • 19
  • 17