Browse by Topic

Popular

Latest

Latest C# Posts

Illustration of a C# using static directive importing static members into a code scope
C#

Using Static in C# to Simplify Member Access

c# using static: Learn how the C# using static directive imports static members into scope, with syntax, examples, naming conflicts, and maintainability tradeoffs.

C#using staticstatic memberscode readability
Diagram showing a static local function in C# without captured variables, illustrating allocation-free behavior.
C#

C# Static Local Function: Syntax and Benefits

Learn how C# static local functions can help avoid closure allocations, when to use them, and how they differ from regular local functions.

C#local functionsstatic modifierclosures
Illustration showing a C# static method called directly on a type without an instance object.
C#

C# Static Method: Syntax, Behavior, and Tradeoffs

Understand C# static methods: declaration syntax, calling conventions, thread-safety implications, and when instance methods are a better design.

C#static methods.NETOOP design
Diagram showing a static variable shared across multiple instances of a C# class.
C#

C# Static Variable: Lifetime and Thread Safety

Learn how static variables work in C#: declaration, initialization, lifetime, thread safety, and common pitfalls for shared state.

C#staticthread safetyclass members
Diagram showing static members shared across instances in C#
C#

C# Static Keyword: Class-Level Members Explained

c# static keyword: Understand the C# static keyword: how static members behave, when to use them, and common pitfalls in class design and multithreading.

static keywordstatic classesstatic membersclass design
Illustration of a C# object with an init-only property being set once during initialization, representing immutability.
C#

C# Init Property: Immutable Object Initialization

Learn how C# init-only properties allow object initializer syntax while preventing assignment after construction, and how they compare with set accessors and readonly fields.

C#init-onlyimmutabilityobject initializer
A C# code snippet showing a required property declaration with a compiler check icon indicating compile-time enforcement.
C#

C# Required Property: Enforcing Initialization

Learn how the C# required modifier enforces property initialization at compile time, including object initializers, constructors, SetsRequiredMembers, and serialization considerations.

C# required modifierobject initializersconstructor designcompile-time validation
Illustration of C# property validation showing a validation shield checking property boxes on a code object diagram.
C#

C# Property Validation: Choosing the Right Approach

Compare DataAnnotations, IValidatableObject, custom attributes, and setter checks to decide where C# property validation belongs in your application.

DataAnnotationsIValidatableObjectASP.NET CoreModel Validation
Illustration of a C# property with a visible backing field and accessors, representing the full property syntax.
C#

C# Full Property: Syntax and When to Use It

c# full property: Understand the C# full property syntax, its backing field, and when to use it over auto-implemented properties for validation, computed values, and t...

C# propertiesbacking fieldsget set accessorsvalidation
Diagram showing a C# property with multiple default value assignment options: initializer, constructor, and backing field.
C#

c# property default value: Setting Initial Values Correctly

c# property default value: Learn how to set default values for C# properties using initializers, constructors, and backing fields, and understand the runtime behavior...

C#property initializerconstructorbacking field