C# casting and type conversion: explicit cast, as, is, Convert, implicit
Learn how to cast and convert types in C#: explicit and implicit casts, the as and is operators, the Convert class, and safe casting patterns.
Practical C# code snippets: short, copy-paste ready, and organized by topic.
Learn how to cast and convert types in C#: explicit and implicit casts, the as and is operators, the Convert class, and safe casting patterns.
Integer overflow in C# silently wraps by default. Learn how checked and unchecked contexts work and how to handle arithmetic overflow safely.
Which C# collection should you use? Compare List, Array, Dictionary, HashSet, Queue, Stack, and LinkedList by Big-O complexity and use case.
Copy-paste C# DateTime.ToString format examples for yyyy-MM-dd, ISO 8601, logs, filenames, UTC, and localized output.
Learn C# DateTime.ToString formats for yyyy-MM-dd, yyyyMMdd, HH:mm:ss, ISO 8601, filenames, logs, and common mistakes such as mm vs MM and hh vs HH.
Learn how to add, update, find, and iterate a C# Dictionary. Compare Add, indexer assignment, TryAdd, TryGetValue, and ContainsKey with practical examples.
Learn C# enums with Enum.GetValues, declaration, iteration, Flags, conversion to string, parsing, and practical examples of named integer constants.
Learn C# events: declaring with EventHandler, raising, subscribing and unsubscribing, custom EventArgs, and safe invocation patterns.
Go beyond basic try/catch in C#: throw vs rethrow, custom exception classes, exception filters with when, and production-ready handling practices.
Write type-safe, reusable C# code without casting or boxing. Learn generic classes, generic methods, and constraints with the where keyword.
Learn how to parse GUIDs with Guid.Parse and Guid.TryParse, format them with N, D, B, P, and X, and normalize values for storage or display.
Generate, parse, format, and compare GUIDs in C# with Guid.NewGuid(), Guid.Parse(), TryParse, ToString formats, and Guid.Empty.
Understand when to use Guid.Empty, default(Guid), and new Guid() in C# and how they compare in guard clauses and nullable code.
Learn what a C# interface is, how to define and implement one, use explicit members, and choose between an interface and an abstract class.
Use C# nullable value types (int?, bool?, DateTime?) to represent a missing value. Learn Nullable<T>, HasValue, GetValueOrDefault, and common patterns.
Learn C# pattern matching with is expressions, switch expressions, type patterns, property patterns, relational patterns, and list patterns.
Learn C# properties: auto properties, get/set accessors, init-only properties, computed properties, and how they differ from fields.
Generate random integers in C# with Random.Shared.Next, Random.Next, and NextInt64. Learn ranges, repeatability, and when to use RandomNumberGenerator.
Learn how a C# record differs from a class: value equality, immutability, with expressions, inheritance, and record struct examples.
Learn Stack<T> and Queue<T> in C#: push/pop/peek, enqueue/dequeue/peek, performance characteristics, and real-world use cases for each.