0
0
CsharpHow-ToBeginner · 3 min read

How to Install .NET SDK for C# Development

To install the .NET SDK for C# development, download it from the official Microsoft website at https://dotnet.microsoft.com/download and run the installer for your operating system. After installation, verify it by running dotnet --version in your command line to confirm the SDK is ready to use.
📐

Syntax

The installation process involves downloading the .NET SDK installer and running it on your system. After installation, you use the dotnet command-line tool to create and manage C# projects.

Key commands:

  • dotnet --version: Checks the installed SDK version.
  • dotnet new console: Creates a new C# console app.
  • dotnet run: Runs the app.
bash
dotnet --version

dotnet new console -o MyApp
cd MyApp
dotnet run
Output
7.0.100 Hello, World!
💻

Example

This example shows how to verify the .NET SDK installation and create a simple C# console application.

bash
dotnet --version

dotnet new console -o HelloWorldApp
cd HelloWorldApp
dotnet run
Output
7.0.100 Hello, World!
⚠️

Common Pitfalls

Common mistakes when installing the .NET SDK include:

  • Not downloading the SDK but the runtime only, which does not include tools to build apps.
  • Not adding dotnet to your system PATH, causing command not found errors.
  • Using an outdated SDK version incompatible with your project.

Always download the latest SDK version and restart your terminal after installation.

bash
REM Wrong: Trying to run dotnet commands without SDK installed
> dotnet --version
'dotnet' is not recognized as an internal or external command

REM Right: After installing SDK and restarting terminal
> dotnet --version
7.0.100
Output
'dotnet' is not recognized as an internal or external command 7.0.100
📊

Quick Reference

Summary tips for installing and using the .NET SDK:

  • Download from official site.
  • Choose SDK, not just runtime.
  • Verify installation with dotnet --version.
  • Create projects with dotnet new.
  • Run projects with dotnet run.

Key Takeaways

Download and install the .NET SDK from the official Microsoft website.
Verify installation by running 'dotnet --version' in your terminal.
Use 'dotnet new' to create new C# projects and 'dotnet run' to execute them.
Ensure the SDK is added to your system PATH to use dotnet commands anywhere.
Avoid installing only the runtime if you want to build and run C# applications.