In this lesson, you will learn about the syntax of a program in the C# programming language by creating a simple, yet famous program called “Hello World!”
Before you get started, let’s create a simple program in C#. Use the Project we created in the previous lesson, then add the code below to the Program.cs file:
The program above output the string “Hello World!” to the console.
using System
: namespace used in this exampleclass Learnmodo
: class name that contains the programstatic void Main(string[] args)
: The program’s entry point.{
: the open bracket for the class Learnmodo.{
: the open bracket for the function Main.Console.WriteLine("Hello World!");
: The statement that print Hello World!, using the WriteLine function.}
: the close bracket for the function Main.}
: the close bracket for the class Learnmodo.As you can see, classes and functions code are enclosed between two brackets {}
. Program statement always ends with the semi-column;
Keep in mind that C# is case sensitive, so console is not the same as Console.
This is the simplest form of programs in C#. In the next lesson, you will learn about different types of Comments in C# and their usage.