Pages

Topics

Tools

↑↓navigate↵openescclose

All syntax guides

Short, practical guides on programming syntax, language fundamentals, and the tools developers reach for every day.

3,980 guides across 14 topics

Topics

Latest guides

Illustration comparing compile-time type inference with runtime dynamic binding in C#.
C#

C# Dynamic vs Var: Type Safety and Runtime Behavior

C# dynamic vs var: Understand the real differences between compile-time type inference and runtime binding, including performance costs, error handling, and when to choose each.

C#dynamic keywordtype inferencestatic typing
Illustration contrasting the C# dynamic keyword with the object type, showing runtime binding versus compile-time casting.
C#

c# dynamic vs object: Choosing the Right Type

c# dynamic vs object: Compare C# dynamic and object types: runtime behavior, performance implications, and when to use each for maintainable code.

dynamic keywordobject typeruntime bindingtype safety
Illustration of C# dynamic keyword showing flexible binding at runtime between two objects
C#

Using the C# Dynamic Keyword Safely

c# dynamic keyword: Learn when and how to use the `dynamic` keyword in C# for runtime binding, interoperability, and reflection scenarios, including performance and sa...

dynamic typeruntime bindingtype safetyreflection
Illustration of a magnifying glass inspecting a generic type container labeled List<T> with type arguments being extracted.
C#

Detecting Generic Types with C# Reflection

Learn how to detect generic types with C# reflection: inspect type properties, read generic arguments and definitions, and resolve generic interfaces and base classes.

C#ReflectionGeneric TypesType System
Illustration of C# Activator.CreateInstance creating an object at runtime from a type reference.
C#

C# Activator.CreateInstance: Runtime Object Creation

Learn how to use C# Activator.CreateInstance to create objects at runtime, pass constructor arguments, handle exceptions, and evaluate performance tradeoffs.

C#ReflectionRuntime Type CreationActivator
Diagram showing a C# type being inspected at runtime with PropertyInfo metadata extracted from its properties.
C#

C# Reflection: Get Properties at Runtime

Use Type.GetProperties() to inspect and manipulate C# properties at runtime: retrieve PropertyInfo metadata, filter with BindingFlags, read and write values, and avoid common reflection pitfalls.

ReflectionPropertyInfoBindingFlagsType Metadata
Illustration of C# AttributeUsage controlling where custom attributes can be applied, with targets like classes and methods shown as bounded regions.
C#

C# AttributeUsage: Controlling Custom Attribute Application

Learn how to use AttributeUsage in C# to define valid targets, allow multiple instances, and control inheritance for custom attributes.

C# AttributesAttributeUsageCustom AttributesReflection
Diagram showing a C# method with params keyword accepting multiple arguments into an array or collection icon.
C#

C# Params Collection: Syntax, Behavior, and Pitfalls

Learn how C# params handles variable arguments with arrays and the C# 13 params collections feature, including syntax, performance tradeoffs, and common mistakes.

C# paramsvariable argumentsIEnumerablearrays
Editorial diagram of collection elements spreading into a combined C# collection expression
C#

C# Collection Expression Spread Element: Syntax and Behavior

Use the `..` spread element in C# collection expressions to copy elements from an existing collection into arrays, lists, spans, and immutable arrays. Includes syntax, runtime behavior, allocation tradeoffs, and edge cases.

C# 12collection expressionsspread elementarrays
Diagram showing a Span<T> referencing a segment of an array, with arrows indicating zero-copy slicing.
C#

C# Span Usage: Process Memory Slices Without Allocations

c# span usage: Learn how to use Span<T> in C# to slice arrays and strings, avoid allocations, and process memory efficiently in high-performance code.

Span<T>Memory<T>ref structperformance