It's hard to say what you don't understand, probably few things.
First thing to understand is: typing system. All objects are derived from
System.Object
. Value objects, such as the object of primitive types, implement
System.Object
members through
boxing.
The thing is: there are many
Console.WriteLine
methods working with any kinds of parameters, including arbitrary number of parameters via
param
specifier. Here is what they essentially do: for each parameter, the method calls its overridden
System.Object.ToString()
method.
For example,
Console.WriteLine(samp[0]);
Console.WriteLine(samp[1]);
But you pass
samp
, which is a reference-type object, an array. For such objects, default
System.Object.ToString()
return is just the object type. Indeed, there is no any obvious predefined way to show content of an arbitrary object. When you define your own class or structure types, you can always override this instance method, using any instance members and any calculations to return some string, the object of the type
System.String
.
—SA