Reference three variables in Console.WriteLine in CSharp

Description

The following code shows how to reference three variables in Console.WriteLine.

Example


  // w  ww. jav  a 2  s.  c o m
  
  
     

using System;
using System.Collections.Generic;
using System.Text;

class Program {
    static void Main(string[] args) {
        int theInt = 90;
        double theDouble = 9.99;
        bool theBool = true;

        Console.WriteLine("Int is: {0}\nDouble is: {1}\nBool is: {2}",theInt, theDouble, theBool);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Development »




Console
Encoding
Environment
Random