STRUCTURE OF A C# PROGRAM
We will see the general structure of a program written with the C Sharp language.
LINK TO LIST OF LANGUAGE RESERVED WORDS
These keywords cannot be used as identifiers.
THE FIRST C# PROGRAM
- Let’s create a folder and name it Corso C#. I created it under the main Windows 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.
- 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.
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.
Leave A Comment