O'Reilly logo

Visual C#® 2012: How to Program, Fifth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.5. Formatting Text with Console.Write and Console.WriteLine

Console methods Write and WriteLine also have the capability to display formatted data. Figure 3.13 outputs the strings "Welcome to" and "C# Programming!" with WriteLine.

 1   // Fig. 3.13: Welcome4.cs  2   // Displaying multiple lines of text with string formatting.  3   using System;  4  5   public class Welcome4  6   {  7      // Main method begins execution of C# app  8      public static void Main( string[] args )  9      { 10         Console.WriteLine( "{0}\n{1}", "Welcome to", "C# Programming!" ); 11      } // end Main 12   } // end class Welcome4

Welcome to C# Programming!

Fig. 3.13. Displaying multiple lines of text with string formatting. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required