Another question about arrays. When i create an array and fill it from keyboard, the console shows several System.Object[] instead of the value I set. For example, if i create a [5] array i get 36 System.Object[] instead of my 5 values. Why is that? This is a code I´m using:
object[] row = new object[5];
public void fill()
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine("Set the values" + (i+1));
row[i] = Console.ReadLine();
}
Console.ReadKey();
}
public void view()
{
Console.WriteLine("The values are:");
for (int i = 0; i <= 5; i++)
{
Console.Write("\n");
for (int j = 0; j <= 5; j++)
{
Console.Write(row);
}
}
Console.ReadKey();
}
static void Main(string[] args)
{
Program objeto = new Program();
objeto.fill();
objeto.view();
Console.ReadKey();
}
There are no error messages, but when on screen i get this afer setting the 5 values:
The values are:
System.Object[]System.Object[]System.Object[]System.Object[]System.Object[]System.Object[] System.Object[]System.Object[]System.Object[]System.Object[]System.Object[]System.Object[] System.Object[]System.Object[]System.Object[]System.Object[]System.Object[]System.Object[] System.Object[]System.Object[]System.Object[]System.Object[]System.Object[]System.Object[] System.Object[]System.Object[]System.Object[]System.Object[]System.Object[]System.Object[] System.Object[]System.Object[]System.Object[]System.Object[]System.Object[]System.Object[]
What can I do?