Skip to content
wannacode

The language you are learning

Problem

Why C#

There are hundreds of programming languages. Each one is good for something, but not equally good for everything. Before you spend months on one of them, it is fair to know where you will use it.

C# (pronounced "see sharp") is the language of Microsoft's .NET platform:

  • games with Unity: Unity scripts are written in C#, from small phone games to big titles;
  • websites and web services with ASP.NET Core;
  • Windows applications: from accounting software to office tools;
  • cloud services, especially in Azure, Microsoft's cloud.

C# dates from 2000 and moves fast: a new version with new features comes out almost every year.

The idea

From text to program

The program you write is plain text in a file. Here is a whole program:

Program.cs
class Program
{
static void Main()
{
Console.WriteLine("Order #1024 has been accepted.");
}
}
Output
Order #1024 has been accepted.

Do not worry about the words in it for now. We will get to them in the lesson "Your first program". What matters here is something else: the computer's processor does not understand this text. Something has to translate it.

  1. You write the source code in a file named Program.cs.
  2. The C# compiler checks the text for errors and translates it into IL (Intermediate Language): a file with the .dll extension. IL is not made for any particular processor.
  3. .NET (more precisely, the part of it that runs programs, the CLR) reads the IL and runs it on your computer.

There is a .NET for Windows, macOS and Linux. That is why the same compiled program runs on all of them. This is called platform independence.

class Program
{
static void Main()
{
Console.WriteLine("Order #1024 has been accepted.");
}
}
Step by step, in words
  1. You write the source code: plain text in the file Program.cs.
  2. The C# compiler reads the text and checks it for errors.
  3. Out comes IL, a file with the .dll extension. It is not made for any particular processor.
  4. The same .dll goes unchanged to Windows, macOS and Linux.
  5. The CLR on each system runs the IL. The output is the same.
More precisely, if you are curious
  • The CLR does not translate the whole program ahead of time. It translates parts of it into machine code while the program runs, and it optimizes harder the parts that run most often. This is called JIT compilation (just-in-time).
  • Memory. Every program takes up memory for its data. In languages like C, the programmer frees the memory that is no longer needed, and if they forget or get it wrong, the program starts taking more and more memory or crashes. C# does this for you: the garbage collector finds the data the program can no longer reach and frees its memory.
  • The old .NET Framework ran only on Windows. Today's .NET (from .NET Core on) is a separate platform that runs everywhere. If you find advice online about .NET Framework, it may not apply to you.

The idea

What you will learn

The course is made of modules. Each module uses only things from the ones before it:

  1. Language basics: variables, input and output, calculations, conditions, loops, arrays, text.
  2. Methods: code you write once and call many times.
  3. Classes and objects: your own types, such as Order or Student.
  4. Inheritance and polymorphism: what several types share, in one place.
  5. Errors and exceptions: what the program does when something goes wrong.
  6. Web: how the internet works, websites with ASP.NET MVC, services with WebAPI and desktop apps with WPF.

Off the main path there are games and projects: whole programs you build step by step.

Two things C# is known for stay outside this course: LINQ (queries over data right in the code, such as "the orders over €100, sorted by date") and threads (several things the program does at the same time). After the course you will have everything you need to learn them on your own.

The idea

How you learn here

Each lesson is a series of cards, one idea per card. It usually starts with a real-world problem, then shows what is really going on, often with an animation next to the code. After that comes a small task: predict the output, fill in what is missing, find the bug. At the end there is an exercise you solve in your own editor, and a short quiz.

Your progress is saved in the browser: the lesson picks up from the card you reached.

The map of the whole course is on the course home page.

Do not skip the exercises. Reading code and writing code are different skills, and the second one comes only from writing.

The idea

Errors are part of the job

Your first programs will often not compile. You will forget a semicolon, a quote or a brace, and the compiler will refuse.

This is not a grade on you. The error message is there to help: it tells you which line the problem is on and what it is. Experienced programmers see these messages every day too. The difference is that they have learned to read them calmly. We will start reading them in the very first lesson with code.

If something will not work for a long time, leave it and come back a bit later. Often you spot the error right away when you look at it again.

In short

In short

  • C# is used for games with Unity, the web with ASP.NET Core, Windows apps and the cloud.
  • The source code (Program.cs) is compiled into IL (.dll), and .NET runs it on any system.
  • Memory is freed automatically by the garbage collector.
  • The course is made of modules, and each lesson of cards. The exercises are in your own editor.
  • An error message is help, not a grade.

Next comes getting your computer ready: what to install so you can run your first program.

Made by Ivo Gergov as part of Evo Tech's campaign for accessible programming education ·