Welcome to the first step of your journey as a C# developer. Before writing a single line of code, it's worth understanding what this language is, why millions of developers around the world use it, and what makes it special compared to other options. This lesson gives you the big picture: key features, a bit of history, the .NET ecosystem C# lives in, and a first (already annotated) look at a "Hello World" program so that, from minute one, you can see what real code actually looks like. Throughout the course we'll be building a running project called BiblioTech, a library management system, so we'll also introduce that idea here so you know where we're headed.
Contents
- What is C#
- Key features of the language
- Brief history and relevant versions
- The .NET ecosystem
- Why learn C#
- Introducing the running project: BiblioTech
- First look at a "Hello World" program
What is C#
C# (pronounced "C Sharp") is a modern, general-purpose programming language created by Microsoft and currently developed as an open-source project under the .NET Foundation. It's used to build practically any type of application: console programs, desktop applications, websites and web APIs, video games, mobile apps, cloud services, and much more.
C# was designed from the ground up to be:
- Simple to read and write, with a clear syntax inspired by languages like C++ and Java.
- Safe, avoiding entire categories of errors common in lower-level languages.
- Powerful, continuously incorporating modern features (functional programming, asynchrony, pattern matching...) without losing its object-oriented core.
When you write C# code, that code is compiled into an intermediate language called IL (Intermediate Language), which the CLR (Common Language Runtime, the .NET execution engine) then translates into machine code at the moment the program runs. This process is called JIT (Just-In-Time) compilation, and it's what allows the same C# program to run on Windows, Linux, or macOS without changing the source code.
Key features of the language
Here are the features that define C# and that we'll explore in depth throughout the course:
| Feature | What it means | Why it matters |
|---|---|---|
| Object-oriented | Programs are organized into classes and objects (covered in detail in Module 3) | Makes it easier to organize complex code into reusable pieces |
| Static typing | The type of each variable is known at compile time | The compiler catches many errors before the program ever runs |
| Type safety | Types can't be mixed incorrectly without an explicit conversion | Reduces runtime errors |
| Automatic memory management | A garbage collector frees unused memory | The programmer doesn't have to free memory manually |
| Interoperability | Can coexist with code from other .NET languages (F#, Visual Basic) and even native code | Lets you reuse existing libraries and components |
| Cross-platform | Runs on Windows, Linux, and macOS thanks to modern .NET | The same code works across different operating systems |
| .NET ecosystem | Huge standard and third-party libraries | No need to "reinvent the wheel" for common tasks |
Let's dwell a little longer on three of these ideas, since they are pillars of the language.
Static typing and type safety
In C#, every variable has a defined type (integer number, text, boolean, etc.) that doesn't change over the lifetime of the program. For example, if you declare a variable as an integer, the compiler won't let you later assign it a piece of text by mistake. This is checked before the program runs, during compilation, which lets you catch a huge number of errors early, before they ever reach production.
This contrasts with dynamically typed languages (such as Python or "classic" JavaScript), where a variable's type is determined at runtime and can change freely. C#'s static typing has a cost (you need to be more explicit), but in exchange it offers more safety and better autocomplete and refactoring tools in the editor.
Automatic memory management
When you create data in C#, the language takes care of allocating memory for it. When that data is no longer used, a CLR component called the garbage collector (GC) automatically frees that memory. This eliminates a huge source of bugs present in languages like C or C++, where the programmer must free memory manually (forgetting to do so causes memory leaks, while freeing it twice causes serious crashes). We'll go deeper into how the garbage collector works in Module 6.
Interoperability and the .NET ecosystem
C# doesn't live in isolation: it's part of the .NET platform, which includes:
- A huge base class library (BCL) with ready-made functionality for working with files, text, collections, networking, dates, and much more.
- Command-line tools (
dotnet) for creating, building, and running projects. - A package manager, NuGet, with hundreds of thousands of third-party libraries ready to install and use.
- Other languages that share the same runtime, such as F# or Visual Basic, with which C# can interoperate seamlessly.
Brief history and relevant versions
C# appeared in 2000, courtesy of Microsoft, as part of the first version of the .NET platform. Since then it has evolved steadily, adding new features with every major version. This table summarizes the most relevant milestones for a developer starting out today:
| Version | Approximate year | Key addition |
|---|---|---|
| C# 1.0 | 2002 | First version: object orientation, basic types |
| C# 2.0 | 2005 | Generics (covered in Module 4) |
| C# 3.0 | 2007 | LINQ, anonymous types, var |
| C# 5.0 | 2012 | async/await for asynchronous programming |
| C# 6.0 / 7.0 | 2015-2017 | String interpolation, early pattern matching |
| C# 8.0 | 2019 | Nullable reference types, switch expressions |
| C# 9.0 | 2020 | Records, top-level statements |
| C# 10-12 (current) | 2021-2024 | Continuous improvements: advanced pattern matching, performance, syntax simplification |
You don't need to memorize this table: what matters is understanding that C# is a living language that keeps improving, and that in this course you'll learn the modern way of writing it, including recent features such as top-level statements, which you'll see in the next lesson.
Today, C# runs on .NET (formerly called ".NET Core" to distinguish it from the older ".NET Framework", which was Windows-only). Modern .NET is open source, cross-platform, and is the version we'll use throughout the course.
Why learn C#
Here are some reasons why C# remains one of the strongest options for getting started in professional programming:
- High job demand: it's used at companies of every size, from startups to large corporations, to build web, desktop, mobile, and game applications (with Unity).
- Reasonable learning curve: its syntax is clear and consistent, and the compiler itself helps you catch errors before the program even runs.
- Versatility: with a single language you can build anything from a simple script to a full enterprise system with a database, or even a video game.
- Community and documentation: Microsoft maintains extensive official documentation, and there's a huge global community producing tutorials, forums, and libraries.
- Constant evolution: the language keeps incorporating modern ideas from other paradigms (functional programming, immutability, etc.) while remaining accessible to beginners.
Introducing the running project: BiblioTech
Throughout this course we won't limit ourselves to disconnected, standalone examples. Instead, module by module, we'll build a real project: BiblioTech, a library management system.
The idea behind BiblioTech is simple to understand but rich enough to illustrate every concept in the course:
- A library has books (with a title, ISBN, page count, and whether they're available or not).
- It has members who can borrow books.
- Loans are generated, each with a start date and a return date.
In this first module we'll still be working with simple console programs — variables, arrays,
text — using BiblioTech data as examples (for instance, a book's title, or an array holding
several titles). Later, in Module 3, we'll learn to model these concepts as classes (Book,
Member, Loan); in Module 4 we'll learn to query collections of books with LINQ; in Module 5
we'll learn to save that data to files, JSON, or a real database; and in the final modules
we'll give BiblioTech a graphical or web interface. The course's final project (Module 9) will
be the complete, polished version of BiblioTech, with everything you've learned brought
together.
You don't need to understand yet how any of this is built: just keep in mind that every example in the course will keep adding a piece to this same project.
First look at a "Hello World" program
So you can see what C# code looks like before installing anything, here's the simplest possible program, in its modern form (the one we'll use throughout this course):
// This is the simplest possible program in modern C#
Console.WriteLine("Hello, world from BiblioTech!");Let's go over, at a high level, what each part does (in the next lesson, "Hello World Program", we'll go through it line by line in full detail):
//starts a comment: everything that follows on that line is for humans only, the compiler ignores it.Consoleis a class from the .NET standard library that represents the console (the text window where the program runs).WriteLineis a method of that class: an action you can askConsoleto perform — in this case, "write a line of text and move to the next line".- The text in quotes,
"Hello, world from BiblioTech!", is a string (string), the piece of data we pass to the method so it can print it. - The semicolon
;marks the end of the statement. In C#, almost every statement ends with a semicolon (we'll cover this in detail in the basic syntax lesson).
If you run this program, you'll see on screen:
Note that this example uses the modern form of C# known as top-level statements, which removes the boilerplate that earlier versions of the language always required you to write. You'll see the full version, with that classic structure and a detailed explanation, in lesson 3.
Common Mistakes and Tips
- Confusing C# with C or C++: despite the similar name, C# is a very different language,
much more modern and safe, even though it shares part of the curly-brace
{ }and semicolon;syntax. - Thinking you need to know OOP before starting: that's not the case. In this module you'll learn the foundations of the language without yet using your own classes; object-oriented programming arrives in Module 3, on top of an already solid foundation.
- Wanting to learn "all the theory" before writing code: C# is best learned by practicing. Take advantage of each lesson's exercises to write and run code as soon as possible.
- Tip: don't worry if some technical term (CLR, JIT, garbage collector) isn't entirely clear yet. We'll keep coming back to these concepts in more detail when the time is right (for example, memory management is covered in depth in Module 6).
Exercises
-
Without running anything yet, explain in your own words what it means for C# to be a statically typed language, and give an example of an error the compiler could catch thanks to it.
-
Look at the table of key language features. Pick two features (for example, "automatic memory management" and "interoperability") and explain, in a couple of sentences each, why you think they're useful for a project like BiblioTech.
-
Read the "Hello World" example from this lesson again and modify it mentally (on paper or in a plain text editor, without running it yet) so that instead of greeting the world, it welcomes a library member — for example:
"Welcome to BiblioTech, Maria!". Write out how the complete line would look.
Solutions
-
Static typing means that each variable's type (for example, whether it's an integer or a piece of text) is fixed and checked before the program runs, during compilation. Example of an error caught by the compiler: if we have a variable declared as an integer and try to assign it a piece of text like
"hello", the compiler will raise a type error and won't let the program compile, instead of failing later, during execution. -
Sample answer (may vary):
- Automatic memory management: BiblioTech will constantly create temporary data (for example, lists of books found in a search). Not having to worry about freeing that memory manually greatly simplifies the code and avoids serious bugs.
- Interoperability: if in the future we wanted to take advantage of an existing library written in another .NET language, or integrate BiblioTech with other systems, C#'s interoperability makes that possible without rewriting everything from scratch.
-
The line would look like this:
Console.WriteLine("Welcome to BiblioTech, Maria!");You simply replace the text in quotes with the new message; the structure of the rest of the statement (
Console.WriteLine(...)and the final semicolon) doesn't change.
Conclusion
In this lesson you've gotten a bird's-eye view of C#: what it is, what makes it special (static typing, type safety, automatic memory management, interoperability), a bit of its history and evolution, and why it remains a solid choice for learning to program professionally. You've also met the project that will accompany us throughout the course, BiblioTech, and seen your first real fragment of C# code.
You still don't have anything installed on your computer to write and run your own programs. That's exactly what we'll fix in the next lesson, Setting Up the Development Environment, where you'll install the .NET SDK, choose a code editor, and confirm that everything works correctly before creating your first real project.
C# Programming Course
Module 1: Introduction to C#
- Introduction to C#
- Setting Up the Development Environment
- Hello World Program
- Basic Syntax and Structure
- Variables and Data Types
- Arrays and Strings
Module 2: Control Structures
Module 3: Object-Oriented Programming
- Classes and Objects
- Methods
- Constructors and Destructors
- Inheritance
- Polymorphism
- Encapsulation
- Abstraction
- Structs and Records: Value Types and Reference Types
Module 4: Advanced C# Concepts
- Interfaces
- Delegates and Events
- Pattern Matching and Modern C# Features
- Generics
- Collections
- LINQ (Language Integrated Query)
- Asynchronous Programming
Module 5: Working with Data
- File I/O
- Serialization
- Database Connectivity
- Entity Framework
- Working with JSON and Consuming REST APIs
Module 6: Advanced Topics
- Reflection
- Attributes
- Dynamic Programming
- Memory Management and Garbage Collection
- Multithreading and Parallel Programming
Module 7: Building Applications
Module 8: Best Practices and Design Patterns
- Coding Standards and Best Practices
- Design Patterns
- Dependency Injection and Inversion of Control
- Unit Testing
- Code Review and Refactoring
