Skip to content
iamnoobs

Beginner to advanced · 13 modules · 39 lessons

Learn C#: Beginner to Advanced

Learn C# and .NET from the first console program through object-oriented design, collections, LINQ, file handling, asynchronous programming, testing, and application architecture with guided lessons, code examples, quizzes, checkpoints, and a capstone.

Who this is for: Beginners and developers who want to build .NET console applications, desktop software, web services, automation tools, or games and learn modern C# practices.

Prerequisites: No previous C# experience is required. Examples use modern C# and .NET concepts; availability of some language features depends on the configured target framework and language version. Code examples are educational and are not compiled or executed on this website.

Meet C# and the .NET platform

C#, .NET, and the runtime

C# is a language; .NET provides runtime services and libraries.

C# is a statically typed, general-purpose language commonly used for console apps, desktop software, web APIs, games, and cloud services. Source code is compiled to intermediate language and executed by the .NET runtime.

The .NET SDK includes the command-line tools and build tasks used to create, build, test, and publish projects. Keep the language, SDK, runtime, and libraries conceptually separate.

Guided example

Read through this example; code examples are for learning and are not executed on this site.

// Create a project, then run it:
// dotnet new console -n HelloCSharp
// cd HelloCSharp
// dotnet run
Console.WriteLine("Hello, C#!");

Relevance quest · +10 XP

What does the .NET SDK primarily provide?

Choose your answer

Mark this lesson complete when you are ready.

Module checkpoint: Meet C# and the .NET platform

Create a console project, print a greeting and a calculated value, then build and run it. Intentionally misspell an identifier and use the compiler message to locate the problem.

After this module, you can:

  • Explain how C# source code is built and run on .NET.
  • Create and run a small console application.
  • Recognize namespaces, classes, and the program entry point.

Full curriculum

What you will learn

1. Meet C# and the .NET platform

Beginner

Understand C#, .NET, the SDK, project files, and the first program.

  1. C#, .NET, and the runtime

    C# is a language; .NET provides runtime services and libraries.

  2. The shape of a C# program

    A small console application can use top-level statements.

  3. Build, run, and read errors

    The dotnet CLI supports the everyday development cycle.

Module checkpoint: Create a console project, print a greeting and a calculated value, then build and run it. Intentionally misspell an identifier and use the compiler message to locate the problem.

2. Variables, types, and expressions

Beginner

Work confidently with C# value types, reference types, inference, constants, and conversions.

  1. Variables and type inference

    Declarations give names to values, and var infers a local variable type.

  2. Built-in types and literals

    Built-in types represent numbers, text, characters, booleans, and more.

  3. Constants and conversions

    Constants and conversions make intent explicit.

Module checkpoint: Write a small unit-conversion program with descriptive variables. Try valid and invalid text input, and explain why each conversion succeeds or fails.

3. Operators and decisions

Beginner

Build expressions and use branching to express program rules.

  1. Arithmetic and comparison operators

    Operators combine values into expressions.

  2. Branch with if and else

    if and else choose a path based on a Boolean condition.

  3. Switch statements and expressions

    Switch is useful when one value maps to several alternatives.

Module checkpoint: Create a simple grade calculator. Test values just below, at, and above each threshold, and make sure every possible score has a defined result.

4. Loops, arrays, and iteration

Beginner

Repeat work safely and work with indexed collections.

  1. Count with for

    A for loop keeps setup, condition, and update together.

  2. Visit each item with foreach

    foreach iterates through elements without manual index updates.

  3. Arrays and bounds

    An array stores a fixed number of elements of one element type.

Module checkpoint: Calculate the sum and average of an array. Test an empty array, a single-item array, and a larger array, and prevent division by zero.

5. Methods, parameters, and scope

Beginner

Organize code into reusable methods with understandable inputs and outputs.

  1. Declare and call methods

    Methods give a reusable name to a unit of behavior.

  2. Parameters and argument passing

    C# passes arguments by value by default.

  3. Overloads, optional parameters, and scope

    Related method signatures can share a name.

Module checkpoint: Refactor a calculator into separate methods. Try normal values, negative values, and invalid operations, and document each method’s expected inputs.

6. Strings, collections, and data modeling

Intermediate

Represent and transform text and collections using common .NET types.

  1. Strings and interpolation

    Strings represent text and are immutable.

  2. Lists, dictionaries, and sets

    Choose a collection based on how data is accessed.

  3. Enums, tuples, and records

    Lightweight types can make data intent clearer.

Module checkpoint: Build a small inventory model using a list of items and a dictionary keyed by product code. Explain why each chosen collection fits its role.

7. Classes and object-oriented programming

Intermediate

Model application concepts with classes, objects, properties, and constructors.

  1. Classes and objects

    A class defines a type; an object is an instance of that type.

  2. Constructors and properties

    Constructors establish an object’s initial state.

  3. Static members and object lifetime

    Static members belong to the type rather than one instance.

Module checkpoint: Design a BankAccount class with a constructor, a read-only balance property, and deposit/withdraw methods that reject invalid amounts.

8. Inheritance, interfaces, and polymorphism

Intermediate

Use inheritance and interfaces to model substitutable behavior without excessive coupling.

  1. Inheritance and protected members

    Inheritance shares behavior through a base and derived type relationship.

  2. Interfaces and implementation contracts

    Interfaces describe capabilities that types agree to provide.

  3. Overriding and polymorphism

    Polymorphism lets code call behavior through a shared base or interface.

Module checkpoint: Create an interface for a notification sender and implement console and in-memory versions. Write caller code that can use either implementation.

9. Exceptions, nullability, and debugging

Intermediate

Handle failures deliberately, express nullable intent, and investigate defects.

  1. Exceptions and error handling

    Exceptions represent failures that disrupt normal control flow.

  2. Nullable references and null checks

    Nullable annotations help communicate when a reference may be absent.

  3. Debugging and boundary testing

    Small, repeatable tests make defects easier to isolate.

Module checkpoint: Add validation and error handling to a text-input calculator. Test blank input, malformed numbers, zero division, and normal calculations.

10. Generics, LINQ, and data processing

Intermediate

Write reusable generic code and express data transformations with LINQ.

  1. Generics and type safety

    Generics let types and methods work with specified data types.

  2. Filter and transform with LINQ

    LINQ expresses common collection queries clearly.

  3. Query design and execution

    Readability and predictable execution matter in data pipelines.

Module checkpoint: Given a list of expenses, use LINQ to filter a category, order by amount, project a report-friendly shape, and calculate the total.

11. Files, streams, and JSON

Intermediate

Read and write local data while handling resource lifetime and serialization.

  1. Read and write files

    File APIs allow programs to persist data between runs.

  2. Streams and resource disposal

    Streams support incremental processing of data.

  3. JSON serialization

    Serialization converts objects to a format that can be stored or transmitted.

Module checkpoint: Build a small settings store that loads and saves JSON. Test missing files, invalid JSON, and an expected successful round trip.

12. Delegates, events, lambdas, and async/await

Advanced

Use functions as values, event-driven patterns, and asynchronous operations.

  1. Delegates and lambda expressions

    A delegate represents a method signature that can be invoked through a variable.

  2. Events and publishers/subscribers

    Events let one object notify other objects that something happened.

  3. Asynchronous programming with async and await

    async/await makes asynchronous operations easier to compose.

Module checkpoint: Write an async method that fetches or simulates delayed data. Handle cancellation or failure and avoid blocking with Task.Result or Task.Wait.

13. Testing, project structure, and application design

Advanced

Organize projects, automate checks, and prepare a maintainable application for delivery.

  1. Projects, namespaces, and dependencies

    A clear project structure makes code easier to navigate and maintain.

  2. Unit tests and testable code

    Unit tests verify behavior in small, repeatable scenarios.

  3. Build, test, and publish

    A reliable delivery workflow builds and tests before publishing.

Module checkpoint: Create a small tested Study Tracker with separate model and service logic. Include tests for empty data, invalid duration, and valid additions; then build and publish a Release configuration.

Put it together

C# capstone: Personal Study Tracker

Build a console-based study tracker that records topics, session durations, and dates; lists and filters sessions; summarizes time by topic; validates user input; and saves or loads data as JSON. Keep core logic testable and separate from console interaction.

  1. 1Define a study-session model and specify validation rules for topic names, dates, and non-negative durations.
  2. 2Create focused methods or services to add, list, filter, and summarize sessions.
  3. 3Use collections and LINQ to calculate totals by topic and find the most recent sessions.
  4. 4Add JSON file persistence with clear error handling for missing or malformed data.
  5. 5Write unit tests for normal, empty, duplicate, and invalid cases; build and publish the Release version.

Progress is saved in this browser when local storage is available. You can continue without an account; changing browsers or clearing browser data may remove saved progress. Examples are not executed by the site.