This C# program demonstrates how print variables or values via the console window. In the program, we print the same message using the values of two variables three times to demonstrate variouos methods of printing values to the console window.
using System; namespace XoaX { class Program { static void Main(string[] args) { double dX = 3.95; double dY = 8.1; Console.WriteLine("First"); Console.Write("X = "); Console.Write(dX); Console.Write(" Y = "); Console.WriteLine(dY); Console.WriteLine("Second"); Console.WriteLine("X = " + dX + " Y = " + dY); Console.WriteLine("Third"); Console.WriteLine("X = {0} Y = {1}", dX, dY); } } }
First X = 3.95 Y = 8.1 Second X = 3.95 Y = 8.1 Third X = 3.95 Y = 8.1 Press any key to continue . . .
© 20072024 XoaX.net LLC. All rights reserved.