C# by Examples
Simple Code Snippets
Tags
Regex Tester
About
Terms
Privacy
Back to Home
Examples tagged with
#fundamentals
How to use async and await in C#
#async
#fundamentals
When to Use async/await vs Task.Run in C#
#async
#fundamentals
#performance
C# casting and type conversion — explicit cast, as, is, Convert, implicit
#fundamentals
How to check if string is null or empty
#fundamentals
#strings
C# checked and unchecked — integer overflow explained
#fundamentals
#performance
C# collections guide — List, Array, Dictionary, HashSet, Queue, Stack
#collections
#fundamentals
#performance
When to Use const vs readonly in C#
#fundamentals
#types
How to convert int to enum in C#
#fundamentals
#enums
#types
How to convert string to int in C#
#fundamentals
#types
C# DateTime Format Examples: yyyy-MM-dd, ISO 8601, and More
#fundamentals
#datetime
C# DateTime.ToString Format Cookbook
#fundamentals
#datetime
Delegates, lambdas, Func, and Action in C#
#fundamentals
#modern-csharp
C# Dictionary: Add, Update, Find, and Iterate (With Examples)
#collections
#fundamentals
When to Use Dictionary vs Hashtable in C#
#collections
#fundamentals
C# enum guide — declare, iterate, Flags, and convert to string
#fundamentals
C# events — EventHandler, custom EventArgs, raise and subscribe to events
#fundamentals
#oop
C# Exception Handling — throw, custom exceptions, and exception filters
#fundamentals
#error-handling
When to Use foreach vs for Loop in C#
#fundamentals
#loops
#performance
How to generate random numbers in C#
#fundamentals
#random
C# Generics — generic classes, methods, and constraints explained
#fundamentals
#generics
C# GUID.Empty Explained — Empty, Default, and New Guid()
#fundamentals
#strings
C# GUID: Generate, Parse, Format, and Compare GUIDs
#fundamentals
#strings
C# GUID Parse and Format Reference
#fundamentals
#strings
When to Use HashSet vs List in C#
#collections
#fundamentals
#performance
When to Use IEnumerable vs IQueryable in C#
#linq
#collections
#fundamentals
When to Use Interface vs Abstract Class in C#
#oop
#fundamentals
#design-patterns
C# interfaces — define, implement, explicit implementation, and interface vs abstract class
#fundamentals
#oop
How to Join Strings in C#
#fundamentals
#strings
How to Check if a List is Empty
#collections
#linq
#fundamentals
When to use List vs Array in C#
#collections
#fundamentals
How to use the null coalescing operator in C#
#fundamentals
#operators
How to use nullable reference types in C#
#fundamentals
#types
C# nullable types — int?, Nullable<T>, null handling patterns
#fundamentals
#null-safety
When to use Parse vs TryParse in C#
#fundamentals
#types
Pattern Matching in C# — is, switch, property, and list patterns
#fundamentals
#modern-csharp
#patterns
C# properties — get, set, init, auto properties, and computed properties
#fundamentals
#oop
C# Random Number Guide: Random.Shared, Random.Next, and RandomNumberGenerator
#fundamentals
#performance
How to Read a Text File
#file-io
#fundamentals
C# record types — record vs class, with expressions, and immutability
#fundamentals
#modern-csharp
When to Use ref vs out Parameters in C#
#fundamentals
#methods
C# Stack and Queue — push, pop, enqueue, dequeue, and when to use each
#collections
#fundamentals
C# string[] vs List<string>: Which Should You Use?
#collections
#fundamentals
How to compare strings in C# — ==, Equals, StringComparison, OrdinalIgnoreCase
#strings
#fundamentals
string.Format in C# — Syntax, Format Specifiers, and Examples
#strings
#fundamentals
How to Use String Interpolation in C#
#fundamentals
#strings
C# string methods cheat sheet — Contains, Split, Replace, Trim, and more
#strings
#fundamentals
What is the difference between String and string in C#
#fundamentals
#types
How to use StringBuilder in C#
#fundamentals
#strings
When to Use Struct vs. Class
#fundamentals
#types
#oop
How to Use Switch Expressions in C#
#fundamentals
#patterns
Task.WhenAll, Task.WhenAny, and Task.Run in C#
#async
#fundamentals
#performance
How to use try catch finally in C#
#fundamentals
#exceptions
When to Use Tuple vs ValueTuple in C#
#fundamentals
#types
When to Use var vs Explicit Types in C#
#fundamentals
#best-practices
What is BOM Character in C#
#fundamentals
#strings
#file-io
Write Special Characters to a File in C#
#file-io
#fundamentals
How to Write to a Text File in C#
#file-io
#fundamentals