The .NET Platform and Your First C# Program – C# | Lesson 30
Introduction
The SMS database is built. Now you learn the language that will talk to it: C# (pronounced "C sharp"). C# runs on .NET, a free platform from Microsoft that works on Windows, Linux, and macOS.
In this lesson, you learn what .NET is, what happens when you press Run, and you create the first project of the SMS solution.
By the end of this lesson, you will be able to:
- Explain the parts of .NET: SDK, runtime, CLR, and base class library.
- Describe how C# becomes a running program: compiler, IL, and JIT.
- Create a solution and a console project with the
dotnetcommand. - Read a project file and a
Program.cswith top-level statements. - Run a quick experiment as a single-file app.
Why this matters
Every part of the SMS from here on is C# on .NET: the console tools in Modules 6 to 8, the data access in Module 9, and the Web API in Modules 10 to 12.
When something goes wrong, such as "it works on my machine but not on the server", the cause is often in the platform, not in your code. A developer who knows what the SDK, the runtime, and the build output are can fix it in minutes.
The concept
Example: the parts of .NET
| Part | What it is | Analogy |
|---|---|---|
| C# | The language you write | The recipe |
| Compiler | Turns C# into IL | The person who rewrites the recipe in a standard format |
| IL (Intermediate Language) | The compiled code inside a .dll file | The standard recipe card |
| CLR (Common Language Runtime) | Runs IL, manages memory, handles errors | The cook |
| Base class library | Ready-made code: text, dates, files, networking | The kitchen's tools |
| Runtime | The CLR plus the base class library | A working kitchen |
| SDK | The runtime plus the compiler and the dotnet tools | The kitchen plus the recipe-writing desk |
Users who only run an app need the runtime. You, the developer, need the SDK. You installed it in Lesson 4.
Example: from C# to a running program
- Build: the compiler checks your C# and turns it into IL, saved in a
.dllfile. - Run: the CLR loads the
.dll. - JIT (Just-In-Time) compilation: the first time each method runs, the CLR turns its IL into machine code for this exact computer.
Why the middle step? The same .dll runs on Windows, Linux, and macOS, because each one's
CLR does its own final translation.
Example: .NET, .NET Framework, and versions
| .NET Framework | .NET (this course) | |
|---|---|---|
| Runs on | Windows only | Windows, Linux, macOS |
| Latest version | 4.8.1, maintenance only | 10, released November 2025 |
| Used for | Older business apps | New projects |
Old tutorials and many existing company systems use .NET Framework. The C# language is almost the same, but project files and some libraries differ, so check which one a tutorial uses.
A new .NET version comes out every November. Even numbers, such as .NET 10, are LTS (Long Term Support): Microsoft supports them for three years. That is why companies, and this course, choose .NET 10.
Example: the dotnet commands you will use
| Command | What it does |
|---|---|
dotnet new sln -n Name | Creates an empty solution file |
dotnet new console -n Name -o folder | Creates a console project |
dotnet sln add path.csproj | Adds a project to the solution |
dotnet build | Compiles everything and reports errors |
dotnet run --project folder | Builds, then runs one project |
dotnet --list-sdks | Shows which SDKs are installed |
A solution (.slnx file) groups projects that belong together. By Module 12, the SMS
solution holds a console app, a core library, a data library, an API, and tests.
Apply it to the SMS
Step 1: create the solution and the console project
Open a terminal in your SMSCOURSE folder, the one with database and queries, and run:
dotnet new sln -n SchoolApp
dotnet new console -n SchoolApp.Console -o src/SchoolApp.Console
dotnet sln SchoolApp.slnx add src/SchoolApp.Console/SchoolApp.Console.csproj
You now have SchoolApp.slnx in the root, and the project in src/SchoolApp.Console. The
.slnx format is the new, simpler solution format that .NET 10 creates by default.
Step 2: read the project file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
| Setting | Meaning |
|---|---|
OutputType Exe | Build a program you can run, not a library |
TargetFramework net10.0 | Build for .NET 10 |
ImplicitUsings | Common namespaces, such as System, are available in every file |
Nullable | The compiler warns about possible missing values (Lesson 35) |
Step 3: write the first program
Replace the "Hello, World!" line in Program.cs with the SMS welcome banner:
// Lesson 30: the first program in the SMS solution.
// Prints a welcome banner, today's date, and the .NET version running this code.
using System.Runtime.InteropServices;
Console.WriteLine("NexCoding Public School");
Console.WriteLine("School Management System - console tools");
Console.WriteLine("----------------------------------------");
Console.WriteLine($"Today: {DateTime.Now:dddd, d MMMM yyyy}");
Console.WriteLine($"Running on: {RuntimeInformation.FrameworkDescription}");
Console.WriteLine($"Operating system: {RuntimeInformation.OSDescription}");
This file has no class and no Main method. Since C# 9, a program can start with
top-level statements: the compiler wraps them into a Main method for you. Each line
ends with a semicolon.
Console.WriteLine prints one line. The $"..." text with {...} inside is an
interpolated string, which puts values into text; Lesson 33 covers it.
Step 4: run it
dotnet run --project src/SchoolApp.Console
NexCoding Public School
School Management System - console tools
----------------------------------------
Today: Monday, 5 October 2026
Running on: .NET 10.0.11
Operating system: Microsoft Windows 10.0.26200
Your date, .NET patch number, and operating system will differ. What matters is that it says .NET 10.
Example: what the build produced
dotnet run built the project first. The results are in bin/Debug/net10.0:
| File | Purpose |
|---|---|
SchoolApp.Console.dll | Your code, compiled to IL |
SchoolApp.Console.exe | A small Windows launcher for the .dll |
SchoolApp.Console.pdb | Debug information: lets the debugger map IL back to your lines |
SchoolApp.Console.runtimeconfig.json | Tells the CLR which .NET version to use |
SchoolApp.Console.deps.json | Lists the libraries the app depends on |
You can run the IL directly with dotnet bin/Debug/net10.0/SchoolApp.Console.dll. Never
edit or commit the bin and obj folders; the build recreates them, and .gitignore
keeps them out of git.
Example: quick experiments with a single file
.NET 10 can run a single .cs file without a project:
dotnet run library-assignment/030-library-welcome.cs
This is perfect for trying an idea in a few lines. The SMS itself stays a proper project, because real applications need several files, settings, and libraries.
Example: the same project in an editor
In Visual Studio 2026, open SchoolApp.slnx. Press Ctrl+F5 to run without the
debugger, or F5 to run with it (Lesson 36).
In VS Code with the C# Dev Kit, open the SMSCOURSE folder. The Solution Explorer
panel shows the same solution. All three ways, terminal or either editor, run the same
dotnet tools underneath.
Common mistakes
- Running
dotnet runin the wrong folder. In the root you get "Couldn't find a project to run." Fix: add--project src/SchoolApp.Console, orcdinto the project folder. - A missing semicolon. The build fails with
error CS1002: ; expected, with the line and column. Fix: read the position in brackets, such as(1,45), and add the;. - Wrong letter case.
console.WriteLinefails witherror CS0103: The name 'console' does not exist. Fix: C# is case-sensitive; writeConsole. - Following a .NET Framework tutorial. Project files and setup steps do not match. Fix: check that a tutorial targets .NET 6 or later.
- Editing or committing
binandobj. Fix: change only your source files.
In real projects
A new developer once told me the API "only works on my machine". The server had the ASP.NET Core runtime for an older .NET version, and the app needed .NET 10.
One look at the runtimeconfig.json file and the server's dotnet --list-runtimes
showed the gap. It took two minutes to diagnose.
Knowing what the build produces, and what each file is for, is not theory. It is how you fix deployment problems while everyone else is still guessing.
Best practices
- Use the current LTS version of .NET for new projects.
- Keep one solution per system, with projects inside
srcandtestsfolders. - Build often; fix the first compiler error first, since later errors often come from it.
- Never commit
binandobj; keep a proper.gitignore. - Use single-file apps for experiments, and projects for real code.
Recap
- .NET is the platform; C# is the language; the SDK is what developers install.
- The compiler turns C# into IL in a
.dll; the CLR runs it, and the JIT turns IL into machine code. - .NET runs on Windows, Linux, and macOS; .NET Framework is Windows-only and old.
dotnet new,dotnet sln add,dotnet build, anddotnet runmanage the SMS solution.Program.csuses top-level statements: no class orMainmethod needed.
Homework
Library module task: Create a single-file app, library-assignment/030-library-welcome.cs,
that prints a welcome screen for the school library: the title, today's date, the loan
period (14 days), and the late fine (2 per day). Run it with dotnet run.
A correct result looks like:
NexCoding Public School - Library
---------------------------------
Today: Monday, 5 October 2026
Loan period: 14 days
Late fine: 2 per day
Show the solution
// Library homework, Lesson 30: a welcome screen for the school library.
// A file-based app: run it with dotnet run library-assignment/030-library-welcome.cs
Console.WriteLine("NexCoding Public School - Library");
Console.WriteLine("---------------------------------");
Console.WriteLine($"Today: {DateTime.Now:dddd, d MMMM yyyy}");
Console.WriteLine("Loan period: 14 days");
Console.WriteLine("Late fine: 2 per day");
No project file is needed: dotnet run builds the single file into a temporary project
behind the scenes.
Quiz
What does a developer install to build C# apps?
Show answer
Answer: B. The SDK The SDK includes the runtime plus the compiler and dotnet tools.
What is inside SchoolApp.Console.dll?
Show answer
Answer: B. IL code The compiler turns C# into IL; the JIT turns IL into machine code at run time.
What does the JIT compiler do?
Show answer
Answer: B. Turns IL into machine code when methods first run Just-In-Time: the final translation happens on the computer that runs the app.
You run dotnet run in the SMSCOURSE root and get 'Couldn't find a project to run'. What is the fix?
Show answer
Answer: B. Add --project src/SchoolApp.Console The root holds a solution, not a project; tell dotnet which project to run.
Why is .NET 10 a good choice for a new project?
Show answer
Answer: B. It is an LTS release with three years of support Even-numbered releases are Long Term Support.
Interview questions
Questions are grouped by experience level. Click a question to see a model answer. All questions: C# interview questions.
Fresher (0-2 yrs)
F What is the CLR? concept
The Common Language Runtime is the part of .NET that runs your compiled code. It loads the IL, turns it into machine code with the JIT compiler, manages memory with the garbage collector, and handles exceptions.
F What is IL, and where is it stored? concept
IL (Intermediate Language) is what the C# compiler produces: a platform-neutral set of
instructions stored in the .dll file. The CLR turns it into machine code when the program runs.
F What is the difference between .NET and .NET Framework? concept
.NET Framework is the original, Windows-only platform; version 4.8.1 is the last, and it only gets maintenance. .NET (Core, then .NET 5 and later) is cross-platform, faster, and where all new development happens.
Mid (3-5 yrs)
M What does JIT compilation mean, and why does .NET use it? concept
Just-In-Time compilation turns IL into machine code the first time each method runs, on the
machine that runs it. The same .dll can therefore run on Windows, Linux, and macOS, and the
JIT can optimize for the exact processor.
M What are top-level statements? concept
Code written directly in Program.cs without a class or Main method. The compiler generates
the Main method for you. Only one file in a project can have them, and they are ideal for
small programs and for the startup code of ASP.NET Core apps.
M What files does dotnet build produce, and what are they for? concept
In bin/Debug/net10.0: the .dll with your IL, an .exe launcher on Windows, a .pdb with
debug information, runtimeconfig.json naming the .NET version to use, and deps.json listing
dependencies. They are rebuilt every time and never committed.
Senior (6-9 yrs)
S An app runs on your laptop but fails to start on the server. How do you check whether it is a .NET version problem? scenario
Read the app's runtimeconfig.json to see which framework and version it needs, then run
dotnet --list-runtimes on the server. If the matching runtime is missing, install it, or
publish the app self-contained so it carries its own runtime.
How to answer: Show a methodical check: what the app needs, what the server has, and the startup error message. Mention ASP.NET Core apps need the ASP.NET Core runtime, not just the base runtime.
S How would you organize a .NET solution for a system with an API, shared logic, data access, and tests? design
One solution with projects in src (for example SchoolApp.Api, SchoolApp.Core,
SchoolApp.Data) and tests. Core holds models and rules with no dependencies, Data
references Core, and the API references both. Tests reference what they test.
How to answer: Explain the dependency direction and why: Core must not depend on databases or web
frameworks, so it stays easy to test and reuse. Mention consistent naming and the .slnx format.
Architect / Lead (10+ yrs)
A Framework-dependent or self-contained deployment: how do you choose? design
Framework-dependent apps are small and use the runtime installed on the server, which the operations team patches. Self-contained apps carry their own runtime: larger, but independent of the server, and you must ship updates for security fixes yourself. Containers make this choice simpler, because the image includes the runtime.
How to answer: Compare size, patching responsibility, and control over the version. Tie the decision to how the organization deploys: managed servers, customer machines, or containers.
Resources
- Code for this lesson: git tag
lesson-30-dotnet-platform(code repository coming soon) - Files:
src/SchoolApp.Console/Program.cs,library-assignment/030-library-welcome.cs - Video: coming soon
What's next
Your first program prints fixed text. Next, it starts working with real school values: fees, marks, and dates, stored in variables of the right type. Lesson 31: Variables and data types
Want live sessions, code reviews, and interview preparation? Join the next batch at Sahasra Technologies.