As you can see, There's a code on your person object that returns a string, Console checks for If a type of string with name of ToString exists on your object class or not, If exists then It returns your string:
public override string ToString()
{
return "Name = " + Name + ", Age = " + Age;
}
And {0} Is a formatted message, When you define It to {0} It means printing/formatting the zero Index object that you Inserted Into params arguments of your function. It's a zero based number that gets the index of object you want, Here's an example:
Console.WriteLine("{0} Is great, {1} Do you think of It? {2} Think {0} Is great!", "C#", "What", "I");
// C# Is great, What do you think of It? I think C# Is great!
When you say {0} It gets C# or the [0] of your object[].
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…