Introduction
C# is a modern, object-oriented programming language developed by Microsoft that runs on the .NET platform and is widely used to build web apps, desktop software, games (with Unity), and cloud services.
Learn Python, JavaScript, Java and more with free interactive lessons, real projects and AI-powered help. Beginner-friendly.
Part of the free C# course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
By the end of this lesson you'll understand what C# and .NET are, you'll have written and run your own C# program, and you'll be printing clean, formatted output with Console.WriteLine and string interpolation — the very first skills every C# developer needs.
Think of C# as a universal remote control . Just like one remote can control your TV, sound system, and streaming box, C# can build desktop apps, websites, mobile apps, and games — all with the same language. The .NET framework is the signal receiver that makes everything work together. You learn one "remote" and control an entire ecosystem.
C# (pronounced "C Sharp") is a modern, object-oriented programming language created by Microsoft in 2000. It was designed by Anders Hejlsberg (who also created TypeScript and Delphi) to be powerful yet approachable — combining the performance of C++ with the productivity of languages like Java and Python.
C# runs on the .NET platform , which provides a massive standard library, a garbage collector for automatic memory management, and cross-platform support. With .NET 8+, your C# code runs on Windows, macOS, and Linux. Here's what you can build:
C# is consistently ranked in the top 5 most in-demand programming languages, with average salaries ranging from £35,000–£75,000 (UK) and $60,000–$130,000 (US) depending on specialisation.
You can practise C# right here in the browser, but to run C# on your own machine:
Option 1: Visual Studio (Recommended for Windows)
Use dotnetfiddle.net or the code editors in this course to practise instantly.
1. Your First C# Program
Every C# journey starts with "Hello, World!". Console.WriteLine() prints text to the console and then moves to a new line. The text you want to print goes inside "double quotes" , and the whole statement ends with a semicolon ; . Read this worked example first and run it, then you'll write your own.
Your turn. The program below is almost complete — fill in the two blanks marked ___ with your own text (remember the "double quotes"), then run it.
2. Console Output & String Interpolation
Console.Write() prints without a new line, so the next output continues on the same line, while Console.WriteLine() finishes the line for you. String interpolation — the
quot;..." syntax — lets you drop variables straight into text inside {' curly braces '} , which reads far better than gluing strings together with + . Escape characters like \n (new line) and \t (tab) let you shape the layout.Now you try. Fill in the two blanks: one puts a variable inside interpolation braces, the other prints a number on the same line as some text.
3. A Taste of Variables
Variables store data. C# is strongly typed , which means every variable has a specific type ( string , int , double , bool ) that fixes what it can hold. You'll cover types in depth in the very next lesson, but here's a preview so the next lesson feels familiar:
Q: What's the difference between Console.Write and Console.WriteLine ?
WriteLine prints your text and then moves to a new line. Write prints your text but leaves the cursor right after it, so the next output continues on the same line.
Console lives in the System namespace. The using System; line tells the compiler where to find it. Leave it out and you get CS0103: The name 'Console' does not exist .
Q: Do I really have to write the class and Main every time?
Modern C# (9+) supports "top-level statements" that let you skip them for small programs. But the full structure is what real projects use, so it's worth learning first — that's why this course shows it.
Q: Why did my code break when I typed console.writeline ?
C# is case-sensitive. It must be Console.WriteLine with the capital C , W , and L . Capitalisation is part of the name, not a style choice.
No blanks this time — just a brief and a blank canvas (with a comment outline to keep you on track). Write it yourself, run it, and check your output against the example in the comments. This is exactly the kind of small program you'll build constantly.
Practice quiz
Which method prints text and then moves to a new line?
- Console.Write()
- Console.WriteLine()
- Console.Print()
- Console.Log()
Answer: Console.WriteLine(). Console.WriteLine() prints the text and then moves the cursor to a new line; Console.Write() stays on the same line.
Which line must be at the top so you can use Console?
- import System;
- using System;
- include System;
- namespace System;
Answer: using System;. Console lives in the System namespace, so you need 'using System;' to access it.
Every C# statement must end with which character?
- A colon :
- A comma ,
- A semicolon ;
- A full stop .
Answer: A semicolon ;. Statements end with a semicolon; forgetting it gives the error 'CS1002: ; expected'.
What is the entry point method where a C# program starts running?
- Start()
- Run()
- Main()
- Begin()
Answer: Main(). Main is the entry point — execution begins there.
Which is the correct string interpolation syntax to embed a variable name?
- "Hello {name}"
- quot;Hello {name}"
- f"Hello {name}"
- "Hello " {name}
Answer:
quot;Hello {name}". Interpolation needs the $ prefix, then variables go inside {curly braces}.C# is case-sensitive. Which of these works?
- console.writeline()
- Console.Writeline()
- Console.WriteLine()
- CONSOLE.WRITELINE()
Answer: Console.WriteLine(). It must be Console.WriteLine with capital C, W, and L — capitalisation is part of the name.
Which symbols wrap text (a string) in C#?
- 'single quotes'
- "double quotes"
- (parentheses)
Answer: "double quotes". Strings use double quotes; single quotes are only for a single char like 'A'.
What does Console.Write() do differently from Console.WriteLine()?
- It prints to a file instead
- It does not add a new line at the end
- It only prints numbers
- It clears the screen first
Answer: It does not add a new line at the end. Write() leaves the cursor on the same line, so the next output continues right after it.
What does it mean that C# is strongly typed?
- Code must be typed quickly
- Every variable has a declared type that fixes what it can hold
- All variables are text
- Types are optional everywhere
Answer: Every variable has a declared type that fixes what it can hold. Strongly typed means each variable has a specific type (string, int, double, bool, ...) fixing what it can store.
What platform does C# run on, giving it cross-platform support?
- .NET
- JVM
- Node.js
- Ruby on Rails
Answer: .NET. C# runs on the .NET platform, which works on Windows, macOS, and Linux.