Programming Course in C# ¡Free!

Formats and lines

 Monday, November 05, 2012 published by Exercises C#
Course > Basic concepts > Formats and lines
Create a program in C# to print Hello on screen and then print your name in a separate line. Do it in three ways: ✔ Using only Console.Write. ✔ Using only Console.WriteLine. ✔ Using parameters witch Console.WriteLine or Console.Write.

Input

-

Output

Hello Jonny!
Hello Jonny!
Hello Jonny!
using System;
public class Exercise
{
    public static void Main( )
    {
         // using only Console.Write
         Console.Write("Hello\nJonny!\n");
         
         // using only Console.WriteLine 
         Console.WriteLine("Hello\nJonny!");
         
         // using parameters         
         Console.Write("{0}", "Hello\nJonny!");
    }
}