What does {0} stands for in Console.WriteLine?

前端 未结 5 1239
夕颜
夕颜 2020-12-20 07:20

Given the code :

// person.cs
using System;

// #if false

class Person
{
    private string myName = \"N/A\";
    private int myAge = 0;

    // Declare a          


        
5条回答
  •  感动是毒
    2020-12-20 07:46

    It refers to the index number of the parameter. For example, if you want to print multiple variables you can do this:

    Console.WriteLine("Person details - {0} {1}", person1, person2)
    

提交回复
热议问题