At its simplest, .NET (pronounced “dot net”) is a free, open-source, cross-platform developer platform for building many different types of applications. It provides a programming model, a comprehensive software library, and a runtime environment.
Enterprises (large corporations) don’t just pick tools because they are “cool”; they pick them for stability and ROI (Return on Investment).
This is the most confusing part for beginners because of the naming history. Here is the breakdown:
| Feature | .NET Framework | .NET Core | .NET 5, 6, 7, 8+ |
| Era | 2002 – 2019 | 2016 – 2020 | 2020 – Present |
| OS | Windows Only | Windows, macOS, Linux | Cross-platform |
| Status | Legacy (Maintenance) | Replaced by .NET 5+ | The Current Standard |
| Performance | Good | Excellent | Top-tier / Blazing Fast |
You need a place to write your code (an Integrated Development Environment or IDE).
Let’s look at the “Hello World” code and explain every single word, as this is where the magic starts.
C#
using System;
namespace HelloWorldApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}
using System;: This is a Namespace Import. It tells the computer, “I want to use the standard ‘System’ library which contains basic functions like printing text.”namespace HelloWorldApp: This is a container used to organize your code. It prevents “name collisions” (e.g., if two people name a class “User”, the namespace keeps them separate).class Program: C# is an Object-Oriented language. Everything happens inside a class. Think of a class as a blueprint for a building.static: This means the method belongs to the class itself, not a specific “instance” of the class. You don’t need to “create” a program to run it.void: This is the Return Type. It means “this function does its job and returns nothing back.”Main: This is the Entry Point. When you click “Run,” the computer specifically looks for a folder called Main. If it doesn’t find it, the app won’t start.string[] args: This allows you to pass information into your app when you start it from a command line.Console.WriteLine: This is the command to print text to the screen.When you hit “Run,” a two-step process occurs:
In C#, a variable is a reserved memory location to store values. Because C# is a strongly typed language, you must tell the compiler exactly what kind of data you are storing.
These store the actual data in a part of memory called the Stack.
int: Stores whole numbers (integers) from -2.1 billion to +2.1 billion.long: For much larger whole numbers (64-bit).double / decimal: Used for fractional numbers. Tip: In enterprise finance apps, we use decimal because it has higher precision for money.bool: Short for Boolean; stores only true or false.char: Stores a single character, like 'A', wrapped in single quotes.These store a “pointer” to a location in a memory area called the Heap.
string: A sequence of characters, like "Hello", wrapped in double quotes.object: The “Grandparent” of all types in .NET. It can hold anything, but it’s slower to use.Operators are symbols used to perform operations on variables.
+, -, *, /, and % (Modulus—returns the remainder of a division).== (is equal to), != (not equal), >, <, >=, <=. These always result in a bool.&& (AND): True if both sides are true.
|| (OR): True if at least one side is true.! (NOT): Reverses the result.= (assigns a value), += (adds and assigns), ++ (increments by 1).Logic allows your program to make decisions. Without these, a program would just be a list of instructions running in a straight line.
The most common way to branch logic.
C#
int age = 18;
if (age >= 21) {
Console.WriteLine("Entry permitted.");
} else if (age >= 18) {
Console.WriteLine("Entry permitted with restrictions.");
} else {
Console.WriteLine("Entry denied.");
}
Used when you have many fixed options for a single variable. It is cleaner and faster than writing ten if statements.
C#
string day = "Monday";
switch (day) {
case "Monday": Console.WriteLine("Back to work!"); break;
case "Friday": Console.WriteLine("Weekend is near!"); break;
default: Console.WriteLine("Just another day."); break;
}
Loops allow you to repeat a block of code multiple times. This is essential for processing lists of data.
for Loop: Used when you know exactly how many times you want to repeat (e.g., “Do this 10 times”).C#for (int i = 0; i < 5; i++) { Console.WriteLine("Iteration: " + i); }while Loop: Used when you don’t know how many times it will run; it keeps going as long as the condition is true.do-while Loop: Similar to while, but it guarantees the code runs at least once before checking the condition.foreach Loop: The “Enterprise King.” It is the safest and most readable way to go through every item in a collection (like a list of employees).In the modern era of fancy web apps and mobile games, why do we start with Console Applications?
Console.WriteLine(): Sends data to the user.Console.ReadLine(): Pauses the program and waits for the user to type something and hit Enter.Here is a “mini-program” using everything above:
C#
Console.WriteLine("Enter your score (0-100):");
string input = Console.ReadLine();
int score = int.Parse(input); // Converting string to number
if (score >= 50) {
for (int i = 0; i < 3; i++) {
Console.WriteLine("You Passed!");
}
} else {
Console.WriteLine("Try again next time.");
}