C# Tutorials
C# Tutorials: Learn C# with Free, Tested Examples
Every C# tutorial on AspDotnetHelp.com in one place, grouped by topic. Each guide shows complete code, the output it produces, and why it works. Pick a topic below, or follow the step-by-step C# roadmap if you’re just starting.
By Bijay Kumar, 13-time Microsoft MVP · 112 tutorials · Updated October 2026
C# Basics
Start here if you're new to C#. These cover what the language is, how variables and types work, and how to organize code into methods and namespaces.
Loops, Conditions and Exceptions
Control the flow of a program: repeat work with loops, branch with switch, and handle errors without crashing.
Object-Oriented Programming (OOP)
Classes, inheritance and interfaces are how real C# applications are structured. Begin with the OOP overview, then work through each concept.
Delegates, Events and Anonymous Methods
These features let you pass methods around and react to things that happen in your app. They're the foundation for lambdas and event-driven code.
Strings
Most day-to-day C# work involves text. These tutorials cover checking, comparing, trimming, reversing and converting strings.
- Check if a string is null or empty
- Reverse a string (7 methods)
- String vs StringBuilder
- Check if a string contains a character
- Compare a string with multiple values
- Compare two strings character by character
- Get the first N characters of a string
- Get the first character of each word
- Remove the first or last character
- Remove a specific character
- Remove the last word from a string
- Add leading zeros to a string or number
- Convert a char array to a string
- Convert a string to a byte array
- Convert a list to a comma-separated string
Numbers, Dates and Conversions
Parse user input, format numbers for display and work with dates. Useful for reports, invoices and anything that shows values to users.
- Format a number with commas and decimals
- Convert to 2 decimal places
- Format numbers and dates with ToString
- Convert a string to double
- Convert a string to int without Parse
- Convert a string with leading zeros to int
- Convert a number with commas to decimal
- Convert null to int
- Convert int to a binary string
- Convert int to a hex string
- Random numbers in a range without repeats
- Convert a string to DateTime
- Get the first and last day of a month
- Create a GUID
- Serialize an object to JSON without escape characters
Arrays and Collections
Store and work with groups of values. Start with arrays, then move to List and Dictionary, which you'll use in almost every project.
Files, Folders and Windows Forms
Work with the file system and build simple desktop tools in Windows Forms.
Naming Conventions
Consistent names make code easier to read and review. Start with the complete guide, then check the rules for each kind of member.
C# Programs for Practice
Short programs with complete code and output. They're a good way to get comfortable with loops, conditions and math in C#.
- Add, subtract, multiply and divide two numbers
- Swap two numbers
- Find the largest of three numbers
- Check for a prime number
- Factorial of a number
- Fibonacci series
- Palindrome number
- Armstrong number
- Leap year check
- Calculate a power with loops
- Sum of the first N numbers
- Reverse a number
- Reverse the words of a sentence
- Second largest number in an array
- Numbers above and below the average
- Simple interest
- Compound interest
- Multiplication table
- Natural numbers in reverse order
- Diamond pattern with nested loops
- Alphabet triangle pattern
C# Interview Questions
Getting ready for a C# or .NET developer interview? These collections cover the questions that come up most, with short answers and code.
Frequently Asked Questions
Where should I start if I’m new to C#?
Start with the What is C# overview, then go through variables, data types and loops in the C# Basics section. After that, the C# roadmap shows the full order to follow.
Are these C# tutorials free?
Yes. Every tutorial on AspDotnetHelp.com is free to read, and the complete code for each example is on the page so you can copy and run it.
Which version of C# and .NET do the examples use?
Newer and rewritten tutorials are tested on .NET 10, the current long-term support release. Most examples also work on older .NET versions because they use core language features that haven’t changed.
How long does it take to learn C#?
Most people with some programming background are comfortable with C# basics and object-oriented programming in four to eight weeks of regular practice. Writing the practice programs on this page is the fastest way to build that confidence.
Do I need Visual Studio to follow these tutorials?
No. You can use Visual Studio on Windows or the free Visual Studio Code editor on Windows, macOS or Linux. See how to create a console app in Visual Studio Code.