Console.WriteLine("Please enter your number of the Names : ?");
int x = Convert.ToInt32(Console.ReadLine());
string[] names = new string[x];
for (int i = 0; i < x; i++)
{
Console.Write("Enter Name no.{0} : ", i + 1);
names[i] = Console.ReadLine();
}
Console.WriteLine("the items are {0}", names);
Console.ReadKey();
Now when I want to type down the names, it just prints the first Name entered!
Like if I have 5 names, in the last line in the
Console.WriteLine("the items are {0}", names);
it just prints out the 1st name!
You’ll want to do a loop at the end as well
Either a
forloop or aforeach, the current way you are usingConsole.WriteLine()is using thestring.Format()overload