🚀 C# ile Programlamaya Giriş: Kodlamaya İlk Adımını At, Kendi Projelerini Geliştirmeye Başla!
00HOME 01POSTS 02COURSES 03ELECTRİCAL_ENERGY 04AUTOMOTİVE_ENGİNEERİNG 05TOOLS 06LAB 07GLOSSARY 08TAGS ♡MY LIST ⌕SEARCH
TRENG

Why C#? Installing .NET and Your First Project

Learn what C# and .NET are and where they are used, then install the .NET SDK and create your first console project from the terminal.

What is C#, and why learn it?

C# (pronounced "C sharp") is a strongly typed, object-oriented programming language developed by Microsoft. It is used in a very wide range of areas: desktop applications, websites, mobile apps, games with Unity, and even industrial automation software. It is also a good choice for an electrical-electronics engineer: desktop tools that read data from measurement instruments, draw charts and generate reports can be written in C# in a short time.

C# does not run on its own; it runs on a platform called .NET. .NET brings together the tools that compile your code and a large library of ready-made classes such as "Console", "List" and "File". In other words, C# is the language, and .NET is the runtime environment and library for that language.

What you need

  • .NET SDK: The toolkit that compiles and runs your code. It is free and open source.
  • A text editor: Visual Studio Code (light and free) or Visual Studio Community. Even Notepad is enough to start, but a code editor gives you syntax coloring and error highlighting.
  • A terminal: PowerShell or Command Prompt on Windows.

Installing the .NET SDK

Open the official .NET download page in your browser and download the current LTS version of the "SDK" package (not just the "Runtime"). In the installer, clicking "Next" all the way through is enough. When it finishes, open a new terminal and check the installation:

dotnet --version

If you see a version number such as 10.0.100, the installation is complete. The number on your machine may be different; what matters is that the command does not give an error.

Your first console project

Choose a folder and run these three commands in the terminal, one after another:

dotnet new console -n HelloWorld
cd HelloWorld
dotnet run

The first command creates a folder named HelloWorld with a ready-made project inside it. The second one enters that folder. The third one builds and runs the project. You will see this on the screen:

Hello, World!

Congratulations, you have run your first C# program! Look inside the folder: Program.cs is the file where the code is written, and HelloWorld.csproj is the project's settings file (it holds information such as which .NET version is used and which features are turned on).

Console.WriteLine("Hello, World!");

The Program.cs generated by the template is a single line. In the next lesson you will learn why that one line is enough and what happens underneath.

Tip: dotnet run builds the project every time. After you change and save the code, just run the same command again. If there is an error, the compiler tells you which line it is on; get used to reading error messages early.

What does "compiling" mean?

The computer does not understand C# code directly. The dotnet tool first translates your code into an intermediate form (IL), and while the program runs, this form is converted into machine code. That is why the same program can run on Windows, Linux and macOS. You only type dotnet run; the tool takes care of the rest.

Try it yourself

  1. Create and run a project with the three commands above.
  2. Change the text in Program.cs to your own name: Console.WriteLine("Hello, I am ...");
  3. Save and run it again with dotnet run. See that the output has changed.
  4. Make a mistake on purpose: delete the semicolon at the end of the line, run it and read the error message. Then fix it.

// Mini quiz

Click an option; you will see right away, with the reason, whether it is correct or not.

1. Which toolkit do you need to install to compile and run C# code?
2. Which command creates a new console project?
3. What is the .csproj file in the project folder for?

Mark it when you finish: your progress is saved and you earn +20 XP.

Tip: ← → keys let you move between lessons.