.NET, C#, and Development Setup
Before you start
You need: nothing. This is the first practical article in the track — it assumes no programming background.
You need installed: Visual Studio 2022 or later, with the .NET desktop development workload. This article shows you how to check, and what to do if it is missing.
Time: about 45 minutes, plus the practice.
New to all of this? Start here explains what an application is made of and introduces the school system every example uses. Any word you do not recognise is in the glossary.
Learning objective
Install Visual Studio, create and run a C# console application, and explain what happens between typing code and seeing output.
Topics
- What .NET is, and how it differs from C#
- SDK versus runtime
- Creating a project in Visual Studio
- Solutions, projects, and what each file does
- Program structure — namespace, class,
Main - Compile time versus run time
- Reading and writing console data
- Building the vocabulary the rest of the track uses
.NET and C#
Two different things, confused constantly.
| What it is | |
|---|---|
| C# | The language — the words and grammar you write |
| .NET | The platform — the compiler, the runtime, and the class library your code uses |
You write C#. The compiler turns it into an intermediate form. The runtime executes it. The class library supplies the ready-made types you build on — string, List<T>, DateTime, file access, networking.
Neither is useful without the other. VB.NET and F# also run on .NET, which is why the platform's name is not the language's name.
Modern .NET runs on Windows, Linux and macOS. The older Windows-only .NET Framework still runs many existing systems, and Track 04 covers reading that code. Everything here is modern .NET.
SDK and runtime
| Contains | Who needs it | |
|---|---|---|
| Runtime | Just enough to execute a compiled application | Anyone running the software |
| SDK | The runtime, plus the compiler, the CLI and templates | Anyone writing it |
Install the SDK. It includes the runtime, so you need only one download.
Installing Visual Studio installs the SDK for you. In the Visual Studio Installer, tick the .NET desktop development workload — that is the one this track needs. Add ASP.NET and web development now as well; Tracks 05 and 10 need it, and adding it later means running the installer again.
Checking what you have
- Help → About Microsoft Visual Studio shows the Visual Studio version.
- Tools → Get Tools and Features reopens the installer, where the Individual components tab lists every .NET SDK installed.
- The quickest check of all: start a new project (below) and look at the Framework dropdown. Whatever it offers is what you have.
If the Framework dropdown does not offer .NET 9.0, the SDK is missing rather than the project being wrong. Go back to the installer and add it.
Creating a project
- Open Visual Studio and choose Create a new project.
- Search for Console App. Pick the one whose tags read C#, Windows, Linux, macOS, then Next.
- Project name:
SchoolConsole. Choose a location you can find again. Next. - Framework: .NET 9.0. Leave the other boxes unticked. Create.
- Press Ctrl+F5 to run.
There are two Console App templates and picking the wrong one causes a confusing morning. The other is Console App (.NET Framework) — that is the old Windows-only platform from Track 04. If your new project shows App.config instead of a .csproj you can read, you picked that one. Delete it and start again.
Ctrl+F5, not F5.
| Key | Does | Result for a console app |
|---|---|---|
Ctrl+F5 | Start without debugging | Window stays open: Press any key to continue |
F5 | Start with debugging | Window closes the instant the program ends |
A beginner presses F5, sees a black window flash and vanish, and concludes nothing ran. Use Ctrl+F5 until you actually want to stop on a breakpoint — which is Article 09.
The buttons you will use daily
| Action | Where | Shortcut |
|---|---|---|
| Run without debugging | Debug menu | Ctrl+F5 |
| Run with debugging | The green ▶ button | F5 |
| Build only | Build → Build Solution | Ctrl+Shift+B |
| Clean build output | Build → Clean Solution | — |
| Show Solution Explorer | View → Solution Explorer | Ctrl+Alt+L |
| Show the Error List | View → Error List | Ctrl+\, E |
Keep the Error List open. It is where the compiler tells you what is wrong, and a fresher who does not know it exists reads the same red squiggle for ten minutes instead.
Adding a .gitignore
Visual Studio adds one when you put the project under source control: Git → Create Git Repository, which writes a .gitignore covering bin/ and obj/ automatically.
Do that before your first commit. Adding it afterwards does not untrack files already committed — Track 16 covers why that is awkward to undo.
Project structure
What Solution Explorer shows you:
Solution 'SchoolConsole' (1 of 1 project)
└── SchoolConsole the project
├── Dependencies packages and framework references
└── Program.cs your code
What is actually on disk:
SchoolConsole/
├── SchoolConsole.sln the solution file
└── SchoolConsole/
├── SchoolConsole.csproj the project file
├── Program.cs your code
├── bin/ compiled output — never committed
└── obj/ intermediate build files — never committed
A solution is a container; a project is what builds. One solution can hold many projects — in Article 09 you add a second one for tests, and by Track 10 a real application has three or four. Solution Explorer hides bin/ and obj/ because you never touch them.
To see the project file: right-click the project → Edit Project File. Older Visual Studio versions made you unload the project first; .NET 9 opens it directly.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>
| Element | Meaning |
|---|---|
OutputType | Exe runs; Library is referenced by other projects |
TargetFramework | Which .NET version this builds against |
Nullable | The compiler warns where a null could reach a non-nullable reference |
ImplicitUsings | Common using directives are added automatically |
Nullable is worth understanding early. With it enabled, string name promises never to be null and string? name admits it might be. The compiler then warns you before a NullReferenceException happens rather than after — and null failures are the most common runtime error a beginner hits.
bin/ and obj/ are generated. Delete them and the next build recreates them. They must never be committed.
Program structure
namespace SchoolConsole
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("NexCoding Academy — Student Console");
}
}
}
| Part | Purpose |
|---|---|
namespace | Groups related types and prevents name collisions |
class | A container for data and behaviour |
static | Belongs to the class itself, not to an instance |
void | Returns nothing |
Main | The entry point — where the runtime starts |
string[] args | Arguments passed on the command line |
Main is the entry point. Exactly one method has that role, and the runtime calls it.
Modern C# allows top-level statements — a Program.cs with no visible class or Main:
Console.WriteLine("NexCoding Academy — Student Console");
The compiler generates the class and Main for you. It is convenient for a small script, but this track uses the explicit form, because every real project has classes and methods and hiding them makes the structure harder to learn.
Compile time and run time
Compile time is when the compiler reads your code. Run time is when the runtime executes it. Errors happen at both, and telling them apart is the first debugging skill.
int totalFees = "15000";
error CS0029: Cannot implicitly convert type 'string' to 'int'
A compile-time error means the program was never built. Nothing ran. The compiler names the file, the line and the rule.
string input = Console.ReadLine();
int rollNumber = int.Parse(input); // input was "NCA-2024-0012"
Unhandled exception. System.FormatException: The input string 'NCA-2024-0012' was not in a correct format.
A run-time error means the program built fine and failed while running. The compiler cannot know what a user will type.
There is a third kind neither catches:
decimal balance = account.TotalFees + account.PaidAmount; // should be minus
A logical error compiles, runs, and produces a wrong answer. No error appears anywhere — a student who has paid ₹12,000 shows a balance of ₹27,000 instead of ₹3,000. These are found by testing, not by tooling, and they are the most expensive kind.
Console input and output
using System;
namespace SchoolConsole
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("NexCoding Academy — Student Lookup");
Console.Write("Enter roll number: ");
string rollNumber = Console.ReadLine();
Console.WriteLine("Searching for " + rollNumber + "...");
Console.WriteLine($"Roll number entered: {rollNumber}");
}
}
}
| Method | Does |
|---|---|
Console.WriteLine | Writes, then moves to a new line |
Console.Write | Writes without a new line — right for a prompt |
Console.ReadLine | Reads one line of input, always as string |
Console.ReadKey | Waits for a single key press |
Console.ReadLine always returns a string. Even when the user types 85, you receive "85". Converting it is your job, and Article 02 covers doing it safely.
$"..." is string interpolation — the value of rollNumber is substituted where {rollNumber} appears. Prefer it to + concatenation for readability.
Vocabulary
These terms appear in every remaining article and in every job interview.
| Term | Meaning |
|---|---|
| Compile | Translating source code into a runnable form |
| Runtime | The engine executing your compiled code |
| Type | The kind of a value — int, string, Student |
| Object | A specific instance created from a class |
| Interface | A contract a class promises to fulfil |
| Exception | A run-time error the program can catch and handle |
| Task | A unit of work that may complete later |
| Dependency | Something your code needs supplied to it |
| Namespace | A named grouping of types |
| Assembly | The compiled output — a .dll or .exe |
Learn these as words you can define, not as words you recognise. Being able to say what an exception is separates a candidate who has read about C# from one who has written it.
Errors you will hit
| What you see | Cause | Fix |
|---|---|---|
| A black window flashes and disappears | Ran with F5 | Use Ctrl+F5 |
CS0029: Cannot implicitly convert type 'string' to 'int' | Assigned text to a number | Article 02 — parse it first |
CS1002: ; expected | Missing semicolon, usually on the line above the one reported | Add the ; |
CS0103: The name 'Console' does not exist in the current context | Missing using System;, or the file is not in the project | Add the using, or check Solution Explorer |
Project has App.config and looks unfamiliar | Picked Console App (.NET Framework) | Delete it; create a Console App instead |
| The Framework dropdown has no .NET 9.0 | The SDK is not installed | Tools → Get Tools and Features → add it |
Unable to copy file ... because it is being used by another process | The program is still running from a previous run | Close the console window, then build again |
Read the line number, then look at the line above it. A missing semicolon or brace is reported where the compiler noticed, which is usually one line later than where you made the mistake.
Common mistakes
- Installing the runtime and expecting to build with it
- Picking the .NET Framework template instead of the .NET one
- Pressing
F5for a console app and thinking nothing ran - Committing
bin/andobj/ - No
.gitignorebefore the first commit - Assuming
Console.ReadLinereturns a number - Not distinguishing compile-time, run-time and logical errors
- Closing the Error List and squinting at red squiggles instead
- Disabling
Nullablebecause the warnings are annoying
Practice
- Open Help → About Microsoft Visual Studio and note your version.
- Create
SchoolConsole— File → New → Project → Console App, .NET 9.0. - Run it with
Ctrl+F5, then withF5. Note the difference in the window. - In Solution Explorer, expand the solution, the project and Dependencies.
- Right-click the project → Edit Project File and identify all four elements from the table above.
- Put the project under source control — Git → Create Git Repository — then confirm
bin/andobj/are ignored. - Build → Clean Solution, check
bin/is emptied, thenCtrl+Shift+Band confirm it returns. - Rewrite the generated
Program.csinto the explicitnamespace/class/Mainform. - Cause a compile-time error: assign
"15000"to anint. Find it in the Error List, double-click the row, and confirm it jumps to the line. - Cause a run-time error:
int.Parseon a roll number likeNCA-2024-0012. - Cause a logical error: add
PaidAmountinstead of subtracting it, and confirm nothing warns you. - Prompt for a roll number with
Console.Write, read it, and echo it using interpolation. - Write your own one-sentence definition of each of the ten vocabulary terms without looking.
Exercise 11 is the one to sit with. It is the error class that tooling cannot find for you.
You can now
- Create a console project in Visual Studio and run it with
Ctrl+F5 - Tell the .NET template from the .NET Framework template, and say why it matters
- Find your way around Solution Explorer, the Error List and the Build menu
- Say what a solution is and what a project is
- Explain what the
.csprojfile controls - Tell a compile-time error from a run-time one from a logical one
- Read a value from the console and print it back
- Define the ten vocabulary terms in your own words
Review questions
- What is the difference between C# and .NET?
- Why is installing the SDK enough, when the runtime is a separate download?
- What type does
Console.ReadLinereturn, and why does that matter? - Which error kind produces no message at all, and how do you find it?
Next: Types and operators