2.1 Program structure

Stasoz
3 min readMar 26, 2022

--

You can check this course on my website.

Program execution

All the code that is written on C# is in files with extension .cs. By default there is a Program.cs file in the console type application with following code:

You can add other C# files as needed, but the entry point will be Program.cs.

Case sensitivity

C# is case sensitive language. Depending on the character case, a particular name can represent different variables, classes, methods, etc.

For example, STRING and string are not the same and the compiler will swear in this case.

The same applies not only to reserved words, but also to the names of variables, classes, interfaces, etc. Example:

Statements

Statement is the basic building block of the program. Statement can be absolutely any action: variable declaration, method call, etc. Each statement must be followed by a semicolon (;) otherwise the compiler will swear and the program will not compile.

Statement example:

The instruction set can be placed in a block of code — curly braces {}. Here the code block contains two instructions:

Code blocks can be nested:

Comments

Sometimes you need to describe the code and you can do this using comments. Comments can be single-line and multi-line and they are ignored during compilation.

Example of single-line and multi-line comments:

❗Tip: use Ctrl+K+C in VS 2022 to quickly add a single-line comment.

Project file

Every C# project has a file that is responsible for the general configuration of the project. By default, this file is named Project_Name.csproj.

To open it, you can click twice with a mouse or a PKM and choose ‘Edit Project File’.

After that, the project configuration will open, where you can see all the dependencies and versions of the libraries.

This file may be needed when you need to change the project configuration or see the versions of the libraries.

Contents

Previous article -> 1.6 C# keywords

Next article -> 2.2 Variables

Join to our community in Telegram — https://t.me/itifico

If you want to support me, you can buy me a cup of coffee and I will drink it when I write the next article :)

Donations list:

  1. Dinesh Chintalapudi — 3$
  2. Unknown — 5$
  3. Neisy — 3$

--

--

Stasoz
Stasoz

Written by Stasoz

Full Stack Developer who is inspired by new technologies

No responses yet