Arrangement problem

Updated on July 5, 2017 in [A] C# .Net
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
5 on July 4, 2017

When I run my program, the numbers are arranged like this:

13

14

8

Instead of like this:

13 14 8

I’m learning from C# tutorial so it bothers me a bit when my result looks different from the video, expecially in the “Arrays” video.

please help.

  • Liked by
Reply
0 on July 4, 2017

We can’t help you if you don’t provide us any information. We need code, what you’ve done, what’s the problem and what have you already tried.

 

  • Liked by
Reply
Cancel
2 on July 4, 2017
using System;
using System.Collections.Generic;
namespace A
{
 class MainClass
 {
 public static void Main(string[] args)
 {
 string[] names = new string[3]
 {
 "Tom", "Mike", "Jack"
 };
 foreach (string name in names) 
 {
 Console.WriteLine(name);
 }
 Console.ReadLine();
 }
 }
}

but it looks like this:

the video’s looks like this:

 

on July 4, 2017

Hi nguyenquoctuan832,

You might want to use the method Console.Write() instead of Console.WriteLine() 

Console.WriteLine() makes it so that each string argument you put in your Array is written on a new line instead of the same line.

Regards,

Flipm0de

Wise
on July 4, 2017
Console.Write (name + ", ");
Show more replies
  • Liked by
Reply
Cancel
0 on July 5, 2017

Oh thank you xD problem solved

  • Liked by
Reply
Cancel