Skip to main content

02. Installing .NET SDK and Visual Studio

Level: Beginner

ℹ️ What You'll Learn
  • What software you need to write C# code
  • Install .NET SDK
  • Install Visual Studio Community
  • Create your first C# console project
  • Run your first School Management System program
  • Understand Program.cs and .csproj
  • Troubleshoot common setup problems

Before writing C# code, you need two things:

  1. .NET SDK -- the engine and tools that compile/run C# code
  2. Visual Studio Community -- the editor where you write and run code

Both are free for learning.

What You're Installing

SoftwareWhat It DoesUse in This Course
.NET SDKCompiles and runs C# codeRequired
Visual Studio CommunityFull IDE for writing C# codeRecommended for beginners
Console App templateSimple project typeUsed for first C# practice

The Problem: Why Do We Need Setup?

C# code is not like a normal text note. The computer cannot run it directly.

You write C# code
v
.NET SDK checks and compiles it
v
.NET runtime runs it
v
Output appears on screen

Visual Studio helps you write the code easily. .NET SDK runs the code.

System Requirements

RequirementRecommended
OSWindows 10/11, Mac, or Linux
RAM8 GB minimum, 16 GB better
Disk space5 GB or more
InternetRequired during installation

For beginners on Windows, use Visual Studio Community.

For Mac/Linux, use .NET SDK + Visual Studio Code.

Step 1: Install .NET SDK

  1. Go to: https://dotnet.microsoft.com/download
  2. Download the latest .NET SDK.
  3. Run the installer.
  4. Finish installation using default options.

Important:

  • Install SDK, not only runtime.
  • SDK is needed to create, build, and run projects.
  • Runtime alone is only for running already-built apps.

Step 2: Verify .NET Installation

Open Command Prompt or Terminal and run:

dotnet --version

Expected output:

10.0.xxx

Your exact version may be different. That is okay if the command prints a version number.

Also run:

dotnet --info

This shows installed SDKs and runtimes.

If both commands work, .NET SDK is installed correctly.

Step 3: Install Visual Studio Community

  1. Go to: https://visualstudio.microsoft.com/vs/community/
  2. Download Visual Studio Community.
  3. Run the installer.
  4. Select these workloads:
[OK] .NET desktop development
[OK] ASP.NET and web development

Then click Install.

Why these workloads?

WorkloadWhy Needed
.NET desktop developmentConsole apps and basic C# practice
ASP.NET and web developmentLater Web API and backend development

Step 4: Create Your First C# Project

In Visual Studio:

  1. Open Visual Studio.
  2. Click Create a new project.
  3. Search for Console App.
  4. Choose Console App using C#.
  5. Project name: SchoolManagementSystem
  6. Location: choose your learning folder.
  7. Framework: choose the installed .NET version.
  8. Click Create.

You now have your first C# project.

Visual Studio Setup Instance

Step 5: Run Your First Program

Open Program.cs and replace the content with this:

💻 Try It — Console App
💡 Paste into Program.cs and press F5⌥ GitHub
Console.WriteLine("=== School Management System ===");
Console.WriteLine("C# setup is working.");
Console.WriteLine("Next, we will learn variables.");

Press F5 or click Run.

Expected output:

=== School Management System ===
C# setup is working.
Next, we will learn variables.

If you see this output, your setup is correct.

Alternative: Create Project Using Command Line

You can also create the same project using terminal:

dotnet new console -n SchoolManagementSystem
cd SchoolManagementSystem
dotnet run

What each command does:

CommandMeaning
dotnet new console -n SchoolManagementSystemCreate a new console project
cd SchoolManagementSystemGo inside the project folder
dotnet runBuild and run the project

Project Structure

After creating the project, you will see:

SchoolManagementSystem/
|-- SchoolManagementSystem.csproj
|-- Program.cs
|-- bin/
|-- obj/
File/FolderMeaning
Program.csYour C# code starts here
.csproj fileProject settings
binBuild output
objTemporary build files

For beginners:

Write code in Program.cs.
Do not edit bin or obj.
Do not edit .csproj unless instructed.

What is Program.cs?

Program.cs is the first file you edit in a console app.

Simple example:

Console.WriteLine("Hello C#");

This line prints text on the screen.

In upcoming articles, we will add:

  • Variables
  • Conditions
  • Loops
  • Methods
  • Classes

What is .csproj?

The .csproj file stores project settings.

Example:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>
SettingMeaning
OutputTypeExe means console application
TargetFramework.NET version used by project
NullableHelps catch null-related mistakes
ImplicitUsingsAdds common using statements automatically

Do not worry if XML looks new. Visual Studio manages this file for you.

Essential Commands

These are useful later:

dotnet --version
dotnet new console -n ProjectName
dotnet run
dotnet build
dotnet clean
dotnet add package PackageName
CommandUse
dotnet --versionCheck installed SDK version
dotnet new consoleCreate console app
dotnet runBuild and run
dotnet buildBuild only
dotnet cleanClean build files
dotnet add packageAdd NuGet package

Troubleshooting

ProblemSolution
dotnet is not recognizedRestart terminal or reinstall .NET SDK
Console App template missingInstall .NET desktop development workload
Project will not runCheck if Program.cs has syntax errors
Wrong .NET version selectedChoose installed framework in project settings
Visual Studio is slowClose extra apps or restart computer

When You'll Use This in SMS

Setup is foundation. You'll repeat these steps:

First project: SchoolManagementSystem (this course)

Later projects:

  • ASP.NET Core API (backend)
  • React frontend
  • Database migrations
  • Cloud deployment

Every time: You'll use:

  • Visual Studio (write code)
  • .NET SDK (build + run)
  • dotnet CLI commands
  • Program.cs (starter file)

Get setup right once, and you will not struggle with tools again.


Common Setup Mistakes (3 Critical)

Mistake 1: Installing runtime instead of SDK

Wrong: Install only .NET Runtime.

Result: You can run apps, but cannot create/build projects.

Fix: Install .NET SDK from https://dotnet.microsoft.com/download.

Mistake 2: Skipping workloads in Visual Studio

Wrong: Install Visual Studio without .NET desktop development.

Result: Console App template missing.

Fix: Open Visual Studio Installer and add required workloads.

Mistake 3: Editing .csproj instead of Program.cs

Wrong: Write C# code inside the project file.

Result: Project breaks - .csproj is configuration, not code.

Fix: Write code inside Program.cs.

Setup for School Management System

Your setup is now ready.

Article 03 -> Store student data using variables
Article 04 -> Calculate marks using operators
Article 05 -> Make decisions using if/else
Article 06 -> Repeat tasks using loops
Article 07 -> Reuse code using methods
Article 08 -> Organize data using classes

Best Practices

  1. Use one folder for all course projects.
  2. Name projects clearly, like SchoolManagementSystem.
  3. Run your code after small changes.
  4. Read compiler errors carefully.
  5. Do not delete project files randomly.
  6. Use Visual Studio for learning, CLI for practice.
  7. Keep .NET SDK and Visual Studio updated.

Verify Your Setup

Run these checks before moving to next article:

  • dotnet --version shows a version number
  • dotnet new console -n TestApp creates a project folder
  • Project runs with F5 or dotnet run
  • Program.cs exists in project
  • Console output appears on screen

All checked? Setup is complete. Ready for Article 03.


ℹ️ Video Tutorial

Step-by-step setup walkthrough coming soon. Subscribe to NexCoding YouTube for updates.


Practice Task

Create a new console project named:

CSharpPractice01

Print this output:

My C# setup is ready.
I can create and run console apps.
I am ready for variables.

Try it using either Visual Studio or command line.


🎯 Q1: What software do we need to write C# programs?

You need:

  • .NET SDK to build and run C# code
  • Visual Studio or another editor to write code

For beginners, Visual Studio Community is recommended because it includes project templates, debugger, IntelliSense, and build tools.

🎯 Q2: What is the difference between .NET SDK and .NET Runtime?

.NET SDK is for developers. It can create, build, and run projects.

.NET Runtime is only for running already-built applications.

For learning C#, install the SDK.

🎯 Q3: What is Program.cs?

Program.cs is the main code file in a console application.

For beginner console apps, your code starts there.

Example:

Console.WriteLine("Hello");
🎯 Q4: What is a .csproj file?

.csproj is the project configuration file.

It stores:

  • .NET version
  • project type
  • package references
  • build settings

Beginners usually do not edit it manually.

🎯 Q5: What is the difference between dotnet build and dotnet run?

dotnet build checks and compiles the project.

dotnet run builds and runs the project.

For learning, dotnet run is commonly used because you immediately see output.

🎯 Q6: How do I know my C# setup is correct?

Run these checks:

dotnet --version
dotnet new console -n TestApp
cd TestApp
dotnet run

If the project runs and prints output, your setup is correct.


🤖Use AI to Learn Faster
⚠️ Important for beginners: Do NOT use AI to write your code yet. Type every example yourself. Your brain learns by doing, not by reading AI output. Use AI only to explain and quiz you — not to code for you. Once you have strong fundamentals, AI becomes a powerful productivity tool for repetitive tasks.

Use ChatGPT, Claude, or Copilot to go deeper on .NET SDK setup and C# project structure. Try these prompts:

  • "Explain .NET SDK and Visual Studio setup like I am a beginner"
  • "What is the difference between SDK, runtime, Visual Studio, and Program.cs?"
  • "Give me a checklist to verify my C# setup"
  • "Quiz me with 5 questions about C# setup"

💡 Tip: After reading this article, paste your own code into AI and ask "What could go wrong here and why?" — fastest way to find edge cases and deepen understanding.

Next Article

Variables and Data Types ->

nexcoding.in