C# Program to print Hello World

Program

using System;
namespace Application
{
	public class HelloWorld
	{
		public static void Main(String[] args)
		{
			Console.WriteLine("Hello World!!!");
			Console.WriteLine("Welcome to oodlescoop");
		}
	}
}

This C# program prints "Hello World!!!" and "Welcome to oodlescoop" to the console.

  1. using System;

    • Imports the System namespace, which provides core functionalities, including console input/output.
  2. namespace Application

    • Defines a namespace called Application to group related classes.
  3. public class HelloWorld

    • Declares a class named HelloWorld. In C#, all code must be inside a class.
  4. public static void Main(String[] args)

    • The Main method is the entry point of a C# program.
    • static means it belongs to the class and does not require an instance.
    • void means the method does not return any value.
    • String[] args allows command-line arguments to be passed.
  5. Console.WriteLine("Hello World!!!");

    • Prints "Hello World!!!" to the console.
    • Console.WriteLine() is used for output with a newline at the end.
  6. Console.WriteLine("Welcome to oodlescoop");

    • Prints "Welcome to oodlescoop" to the console on a new line.

Output

$ mcs HelloWorld.cs
$ mono HelloWorld.exe
Hello World!!!
Welcome to oodlescoop