C#: Print a line using WriteLine

This entry is part 4 of 71 in the series C#

To continue using the earlier template that we have generated, we add 2 lines to the code.

Console.WriteLine("Hello, World");
Console.ReadLine();

So the whole program will be as follow:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleHelloApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World");
            Console.ReadLine();
        }
    }
}

The WriteLine() will print out the Hello, World text.

Without the ReadLine(), the program will exit immediately by itself and so we add this line so that we can see the console output.

Click on the Start button and you will see an output similar to below:

console

 

 

Series Navigation<< C#: Build the first console application
C#: using System >>