Browse by Topic

Popular

Latest

Latest C# Posts

A diagram showing a C# switch case branching into multiple outcomes with pattern matching and a a default path.
C#

C# Switch Case: Syntax, Patterns, and Pitfalls

Learn C# switch case syntax, switch expressions, pattern matching, common mistakes, and performance considerations for clean control flow.

switch statementpattern matchingswitch expressionsC# control flow
A visual representation of the C# null coalescing assignment operator assigning a value only when the left operand is null.
C#

C# Null Coalescing Assignment Operator

c# null coalescing assignment operator: Learn how to use the C# null coalescing assignment operator (??=) to assign values only when a variable is null, with practical...

C#Null CoalescingNull HandlingAssignment
Illustration of the C# modulo operator showing division and remainder on a number line.
C#

C# Modulo Operator: Syntax and Common Pitfalls

A practical look at the C# modulo operator: integer and floating-point behavior, negative operands, common pitfalls, and useful code examples.

C#modulointeger arithmeticfloating-point
Illustration of C# arithmetic operators with mathematical symbols and code context.
C#

C# Arithmetic Operators: Syntax, Behavior, and Pitfalls

How C# arithmetic operators behave in practice: integer division truncation, overflow handling, floating-point precision limits, and operator precedence.

C#arithmetic operatorsinteger overflowoperator precedence
Illustration of integer overflow wrapping around versus throwing OverflowException in C#
C#

C# Overflow Handling with checked and unchecked

How C# handles integer overflow by default, how the checked and unchecked contexts change that behavior, and how to enable project-wide overflow checking.

checkeduncheckedOverflowExceptioninteger arithmetic
Illustration of the C# Convert class transforming a value into different data types such as string, integer, and boolean.
C#

C# Convert Usage: Converting Between Base Types

How to use the C# Convert class for type conversion, including null and DBNull handling, culture behavior, and when to choose Convert, Parse, TryParse, or casting.

C#.NETtype conversionConvert class
A magnifying glass over a C# class diagram highlighting method names, representing reflection retrieving methods at runtime.
C#

How to Get Methods with C# Reflection

Learn how to retrieve method metadata with C# reflection, use BindingFlags to filter results, resolve overloads, and cache MethodInfo for better performance.

ReflectionMethodInfoType InspectionRuntime Metadata
Diagram showing an interface bridging a generic method and multiple type instances, representing C# type class emulation.
C#

C# Type Class: Emulating with Interfaces

C# Type Class: Learn how to emulate type classes in C# using interfaces, generic constraints, and static generic classes, with tradeoffs and decision criteria.

C#Type ClassesInterfacesGeneric Constraints
A comparison diagram showing the C# typeof operator resolving a type at compile time and the GetType method discovering the runtime type of an object instance.
C#

C# typeof vs GetType: Compile-Time vs Runtime Type Resolution

c# typeof vs gettype: Learn the difference between C#'s typeof operator and GetType() method, including compile-time vs runtime resolution, inheritance behavior, and p...

C#Type SystemReflectionRuntime Type
A magnifying glass inspecting a C# object to reveal its runtime Type, symbolizing reflection GetType.
C#

C# Reflection GetType: Inspect Runtime Types

Learn how to use C# reflection GetType to inspect runtime types, compare it with typeof, and avoid common pitfalls in real-world code.

C# ReflectionGetType MethodType ObjectRuntime Type Inspection