Pages

Topics

Tools

↑↓navigate↵openescclose

C# guides

Every published C# guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest C# guides

Diagram showing a LINQ query projecting data into an anonymous type with inferred properties.
C#

C# Anonymous Type with LINQ: Projection and Usage

Learn how C# anonymous types work with LINQ for projections, grouping, joins, and composite keys, and when a named DTO is the better choice.

anonymous typesLINQC# programmingtype inference
Illustration of C# anonymous type concept with a projection from a collection to an anonymous object.
C#

C# Anonymous Type: Syntax, Usage, and Limitations

c# anonymous type: Learn how to use C# anonymous types for read-only data projections, their syntax, runtime behavior, and when to prefer tuples or records.

anonymous typesC#LINQtype inference
Editorial illustration of C# dynamic runtime binding showing a runtime binder routing a method call to a resolved object at execution time.
C#

C# Dynamic Runtime Binding Explained with Examples

C# dynamic runtime binding defers member resolution until runtime. Understand how the dynamic keyword works with the DLR, when RuntimeBinderException appears, and the performance trade-offs to expect.

dynamic keywordDLRruntime bindingC# reflection
Illustration of a C# method being invoked dynamically at runtime with reflection and dynamic binding.
C#

C# Dynamic Method Invocation at Runtime

Learn how to call C# methods by name at runtime using reflection, the dynamic keyword, and cached delegates, with practical performance and maintainability tradeoffs.

ReflectionDynamic KeywordDelegatesPerformance
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