c-sharp
  1. c-sharp-hello-world-program

"Hello World" Program - (C# Basic Programs)

The "Hello World" program is a simple program that outputs the text "Hello World" to the console. It is often used as a first introduction to programming and serves as a basic example of how to create and run a program in a specific programming language. In this tutorial, we will discuss how to create a "Hello World" program using C# programming language.

Syntax

The syntax for printing "Hello World" in C# is as follows:

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine ("Hello World");
  }
}

Example

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine ("Hello World");
  }
}

Output

Hello World

Explanation

The program starts with the using System statement, which enables the programmer to use functionality provided by the System namespace. The main function is defined as follows:

public static void Main(string[] args)

This function is the entry point for the program and is called automatically when the program is executed. The Console.WriteLine function is called within the Main function to output the text "Hello World" to the console.

Use

The "Hello World" program is often the first program that new programmers write in any programming language. It serves as an introduction to the basic syntax and structure of a program in that specific language. Additionally, this program can be used to test a new installation of the C# compiler, to ensure it functions correctly.

Summary

In this tutorial, we discussed how to create a "Hello World" program using C#. We provided the basic syntax for the program, an example program, and an explanation of how the program works. We also talked about the use of "Hello World" program for new programmers to provide them an introduction to a specific programming language.

Published on: