In Lesson 1 you learned that .NET is the platform — the kitchen where software gets cooked. Today we pick up the pen and learn the language: C#. Every banking alert, every WhatsApp-style notification sent from a .NET backend, every line of logic that decides "show this movie recommendation" — it is written in a language like this one.
C# might look intimidating at first glance. Curly braces, semicolons, words like namespace. But here is the secret: it reads top to bottom, like instructions on a recipe card. Let us decode your first program together.
What Is C#?
C# (C sharp) is a modern programming language designed by Microsoft for building apps on .NET. It is object-oriented, which means you organize code around "things" (objects) that have data and behaviour — more on that in Lesson 5.
Think of C# as the language you use to write a detailed instruction manual for a robot. The robot (.NET runtime) follows each step exactly. Miss a semicolon and the robot stops and tells you where it got confused — that is a compiler error, and it is your friend, not your enemy.
C# was created to be safer and clearer than older languages. It handles memory automatically so you spend less time fixing crashes and more time building features — like how automatic gearboxes let you focus on the road instead of shifting constantly.
Why Learn C# on .NET?
You could learn many languages. Why C#?
- Industry demand — banks, insurance firms, and SaaS companies hire .NET developers regularly.
- One language, many app types — web, mobile, desktop, cloud, games.
- Great tools — autocomplete, debugging, and error highlighting in Visual Studio feel like spell-check for code.
If .NET is Netflix's streaming infrastructure, C# is the scriptwriters' language for every show on the platform.
Anatomy of a C# Program
Every beginner program shares the same skeleton. Read this slowly — we will explain each line:
// My first C# program
using System;
namespace HelloBank
{
class Program
{
static void Main()
{
Console.WriteLine("Welcome to SecureBank!");
Console.WriteLine("Checking your balance...");
}
}
}
// — a comment. The computer ignores it. Notes for humans, like margin scribbles in a textbook.
using System; — imports a library. System is built into .NET and includes console tools.
namespace HelloBank — a folder-like container for your code. Keeps projects organized when they grow.
class Program — a blueprint grouping related code. Even tiny apps need at least one class.
static void Main() — the front door. When you run the app, execution starts here.
Console.WriteLine(...) — prints text to the terminal window and moves to the next line.
How Does Execution Flow?
You press Run
↓
.NET finds Main() method
↓
Runs line 1: prints welcome message
↓
Runs line 2: prints balance message
↓
Program ends
Computers do not guess. They follow instructions in order unless you tell them to branch (Lesson 4) or repeat (loops, also Lesson 4).
Real-World Example
When you pay a merchant through a UPI-style banking app, a C# backend might run logic like this (simplified):
Console.WriteLine("Payment request received.");
Console.WriteLine("Verifying account balance...");
Console.WriteLine("Payment approved. Receipt sent.");
In production, those messages become database updates and push notifications — but the idea is the same: step-by-step instructions. The user never sees Console.WriteLine, but the same language powers the real API behind the scenes.
Step-by-Step: Run Hello World
Step 1: Open a terminal in an empty folder.
Step 2: Create a project: dotnet new console -n HelloBank
Step 3: Open the folder in VS Code or Visual Studio.
Step 4: Replace Program.cs with the banking example above (or edit the default Hello World).
Step 5: Run: dotnet run
You should see your messages printed in the terminal. Congratulations — you are officially a C# developer.
Main method. Both styles work. We show the full structure so you understand what is happening under the hood.Common Misconceptions
"C# and C++ are the same." They share a name heritage but are different languages. C# is higher-level and easier for beginners.
"One typo ruins everything forever." The compiler tells you the line number. Fix it and run again — iteration is normal.
"Real developers memorize every keyword." They do not. Autocomplete and documentation exist for a reason.
"Comments are optional so I should skip them." Skip them in Hello World if you want — but good comments save you hours later when you forget why you wrote something.
Quick Recap
- C# is the primary language for .NET development.
- Programs start at the
Mainmethod. Console.WriteLineoutputs text for learning and debugging.- Namespaces and classes organize code as projects grow.
- Use
dotnet new consoleanddotnet runto build and execute.
Summary
C# is how you tell .NET what to do — one clear instruction at a time. Like texting a friend exact directions instead of saying "just come over," precise code leaves no room for misunderstanding.
In Lesson 3 we store information: names, balances, ages, and true/false flags using variables and data types.
Frequently Asked Questions
Key Takeaways
- C# is the main language for writing .NET applications.
- Every program has an entry point — typically the
Mainmethod. Console.WriteLineis your first tool for seeing output.- Use
dotnet new consoleanddotnet runto create and execute projects. - Compiler errors point to fixable mistakes — read the message calmly.