About C# by Examples
What Is This Site?
C# by Examples is a free, open educational resource that provides practical, ready-to-run C# code snippets for developers at every level — from beginners picking up their first language to experienced engineers who need a quick reference.
Every example on this site is written to be clear, concise, and immediately copyable. No fluff, no lengthy preambles — just working code with enough context to understand what it does and why.
What You Will Find Here
- Idiomatic C# patterns covering strings, collections, LINQ, async/await, and more
- Side-by-side comparisons (e.g.,
structvsclass,ListvsArray) - Practical examples for everyday tasks such as reading files, formatting dates, and handling nulls
- A growing library of 60+ topics, organized by tag for easy discovery
- A built-in Regex Tester for C# regular expressions
Our Goal
The goal is simple: help C# developers solve problems faster. Whether you search for “how to iterate a dictionary in C#” or “difference between const and readonly”, we want the answer to be here — correct, modern, and easy to understand.
All content targets modern C# (C# 10+) and .NET 6+ unless otherwise noted.
Contact
Have a suggestion, spotted an error, or want to request a topic? Reach out at contact@csharpbyexamples.com.