Console.WriteLine(names) without "[x]" next giving following result. Anybody knows explain please.
System.String[]
using System;
public class ReverseArray
{
public static void Main()
{
string[] names = { "Zach", "Wendy", "Rose", "Marcia" };
int x;
Array.Reverse(names);
for (x = 0; x < names.Length; ++x)
Console.WriteLine(names);
Console.WriteLine();
for (x = 0; x < names.Length; ++x)
Console.WriteLine(names[x]);
Console.ReadKey();
}
}
/*
System.String[]
System.String[]
System.String[]
System.String[]
Marcia
Rose
Wendy
Zach
*/
Loading
Mamta MPosted Feb 22, 2012, 11:56 PM
Since the array itself doesnt contain data, its elements contain data, when you print only the data type is printed.
The data type of the array is System.String[] therefore when you are printing, you get System.String[] as output.
Try it out with an array of ints. You will get System.Int32 as output. That will prove this fact.
Posted Feb 23, 2012, 12:01 AM