STRUCTURE OF A C# PROGRAM

C sharpWe will see the general structure of a program written with the C Sharp language.

Struttura programma
Il token

LINK TO LIST OF LANGUAGE RESERVED WORDS

LANGUAGE RESERVED KEYWORDS

These keywords cannot be used as identifiers.

Statement
Namespace

THE FIRST C# PROGRAM

  • Let’s create a folder and name it Corso C#. I created it under the main Windows directory.
Course directory

THE C SHARP LANGUAGE – OPEN VISUAL STUDIO CODE

  • We open the command prompt and place ourselves in the newly created folder.
  • We type the following command: dotnet new console -o HelloWorld –use-program-main
  • Let’s go to the directory created with the command cd HelloWorld and type code followed by a period to open Visual Studio Code.
Visual Studio Code HelloWorld
  • Let’s open the source of our first program by clicking on program.cs. Source files have a .cs extension
  • We open the terminal integrated in Visual Studio Code by going to the terminal menu -> new terminal and type the following command: dotnet run. This command compiles the source file, creates the Process Assembly and executes the program.
First program run

PROGRAM EXECUTION

  • As you can see, the program was executed correctly and printed the string indicated by the WriteLine “Hello World” method on the screen.
  • If you have not done so you need to install the C # extension for visual studio code in order to have the intellisense available.
Extension

THE C SHARP LANGUAGE – LINK TO PREVIOUS POST

DIGITAL ELECTRONICS

DEEPENING