Practice / c#

C# practice

Every C# exercise, built from a topic you can open beside it.

88 exercises runs offline
c# Quiz new Which value can be used directly as a C# attribute argument? Understand how C# attributes store declarative metadata, how targets, arguments, inheritance, and reflection work, and what generated code gets wrong. beginner 1 min · from Attributes c# Quiz new A project defines `[Cache(60)]` and applies it to a method, but no framework component re… Understand how C# attributes store declarative metadata, how targets, arguments, inheritance, and reflection work, and what generated code gets wrong. beginner 1 min · from Attributes c# Predict the output new What does this program print? Understand how C# attributes store declarative metadata, how targets, arguments, inheritance, and reflection work, and what generated code gets wrong. intermediate 2 min · from Attributes c# Review AI code new Review generated command catalog Understand how C# attributes store declarative metadata, how targets, arguments, inheritance, and reflection work, and what generated code gets wrong. advanced 6 min · from Attributes c# Spot the bug new Spot the bug in the property attribute Understand how C# attributes store declarative metadata, how targets, arguments, inheritance, and reflection work, and what generated code gets wrong. intermediate 4 min · from Attributes c# Spot the bug new Spot the bug in repeated attributes Understand how C# attributes store declarative metadata, how targets, arguments, inheritance, and reflection work, and what generated code gets wrong. intermediate 4 min · from Attributes c# Quiz new Which collection best expresses processing restock requests in arrival order? Choose C# collections by access pattern, equality, order, and concurrency, then avoid bugs involving mutable keys, read-only views, and compound operations. beginner 1 min · from Collections c# Quiz new Which property must hold while an object is a Dictionary key? Choose C# collections by access pattern, equality, order, and concurrency, then avoid bugs involving mutable keys, read-only views, and compound operations. intermediate 1 min · from Collections c# Predict the output new What does this program print? Choose C# collections by access pattern, equality, order, and concurrency, then avoid bugs involving mutable keys, read-only views, and compound operations. beginner 2 min · from Collections c# Predict the output new What counts are printed after the source list changes? Choose C# collections by access pattern, equality, order, and concurrency, then avoid bugs involving mutable keys, read-only views, and compound operations. intermediate 2 min · from Collections c# Review AI code new Review generated product catalog Choose C# collections by access pattern, equality, order, and concurrency, then avoid bugs involving mutable keys, read-only views, and compound operations. advanced 6 min · from Collections c# Spot the bug new Spot the bug in stock cleanup Choose C# collections by access pattern, equality, order, and concurrency, then avoid bugs involving mutable keys, read-only views, and compound operations. beginner 4 min · from Collections c# Quiz new What runtime guarantee does string? add compared with string? Understand C# copy semantics, nullability, numeric conversions, and boxing, then avoid the type errors common in generated code. beginner 1 min · from Data types c# Predict the output new What does this program print? Understand C# copy semantics, nullability, numeric conversions, and boxing, then avoid the type errors common in generated code. beginner 2 min · from Data types c# Predict the output new What does this program print when a nullable value is boxed? Understand C# copy semantics, nullability, numeric conversions, and boxing, then avoid the type errors common in generated code. intermediate 2 min · from Data types c# Review AI code new Review generated invoice importer Understand C# copy semantics, nullability, numeric conversions, and boxing, then avoid the type errors common in generated code. advanced 6 min · from Data types c# Spot the bug new Spot the bug in the order total Understand C# copy semantics, nullability, numeric conversions, and boxing, then avoid the type errors common in generated code. beginner 4 min · from Data types c# Quiz new What extra restriction does a public event impose compared with a public delegate field? Delegates turn methods into type-safe values; events restrict who can publish notifications. Learn invocation lists, identity, capture, and async boundaries. beginner 1 min · from Delegates and events c# Predict the output new Which value does this multicast delegate call print? Delegates turn methods into type-safe values; events restrict who can publish notifications. Learn invocation lists, identity, capture, and async boundaries. intermediate 2 min · from Delegates and events c# Predict the output new What does this program print after one duplicate handler is removed? Delegates turn methods into type-safe values; events restrict who can publish notifications. Learn invocation lists, identity, capture, and async boundaries. intermediate 2 min · from Delegates and events c# Review AI code new Review generated report notifier Delegates turn methods into type-safe values; events restrict who can publish notifications. Learn invocation lists, identity, capture, and async boundaries. advanced 6 min · from Delegates and events c# Spot the bug new Spot the bug in the callback loop Delegates turn methods into type-safe values; events restrict who can publish notifications. Learn invocation lists, identity, capture, and async boundaries. intermediate 4 min · from Delegates and events c# Quiz new Given a public field-like event, what can ordinary code outside its declaring type do? Understand how C# events are declared, subscribed, raised, and released, including real traps around ordering, exceptions, and async handlers. beginner 1 min · from Event subscription and lifetime c# Predict the output new Which lines does this program print? Understand how C# events are declared, subscribed, raised, and released, including real traps around ordering, exceptions, and async handlers. intermediate 2 min · from Event subscription and lifetime c# Predict the output new What does this program print after the same handler is added twice and removed once? Understand how C# events are declared, subscribed, raised, and released, including real traps around ordering, exceptions, and async handlers. intermediate 2 min · from Event subscription and lifetime c# Review AI code new Review generated price notification Understand how C# events are declared, subscribed, raised, and released, including real traps around ordering, exceptions, and async handlers. advanced 6 min · from Event subscription and lifetime c# Spot the bug new Spot the bug in dashboard subscription Understand how C# events are declared, subscribed, raised, and released, including real traps around ordering, exceptions, and async handlers. intermediate 4 min · from Event subscription and lifetime c# Predict the output new Which two lines does this program print? Understand how C# exceptions are thrown, filtered, unwound, and propagated through tasks without losing the evidence needed to diagnose failure. intermediate 2 min · from Exceptions c# Predict the output new What count does the program print after awaiting the combined task? Understand how C# exceptions are thrown, filtered, unwound, and propagated through tasks without losing the evidence needed to diagnose failure. advanced 2 min · from Exceptions c# Quiz new A catch block records a failure and must propagate the same exception. Which statement pr… Understand how C# exceptions are thrown, filtered, unwound, and propagated through tasks without losing the evidence needed to diagnose failure. beginner 1 min · from Exceptions c# Review AI code new Review generated price client Understand how C# exceptions are thrown, filtered, unwound, and propagated through tasks without losing the evidence needed to diagnose failure. advanced 6 min · from Exceptions c# Spot the bug new Spot the bug in customer lookup Understand how C# exceptions are thrown, filtered, unwound, and propagated through tasks without losing the evidence needed to diagnose failure. intermediate 4 min · from Exceptions c# Predict the output new What does the program print after the captured variable changes? Represent lambdas as inspectable and translatable object trees; understand node types, parameter identity, visitors, compilation, and LINQ provider boundaries. intermediate 2 min · from Expression trees c# Predict the output new Which node kind does this program print? Represent lambdas as inspectable and translatable object trees; understand node types, parameter identity, visitors, compilation, and LINQ provider boundaries. beginner 2 min · from Expression trees c# Quiz new A repository must let its database provider translate a caller-supplied filter. Which par… Represent lambdas as inspectable and translatable object trees; understand node types, parameter identity, visitors, compilation, and LINQ provider boundaries. beginner 1 min · from Expression trees c# Review AI code new Review generated dynamic filter Represent lambdas as inspectable and translatable object trees; understand node types, parameter identity, visitors, compilation, and LINQ provider boundaries. advanced 6 min · from Expression trees c# Spot the bug new Spot the bug in dynamic comparison Represent lambdas as inspectable and translatable object trees; understand node types, parameter identity, visitors, compilation, and LINQ provider boundaries. intermediate 4 min · from Expression trees c# Spot the bug new Spot the bug in predicate composition Represent lambdas as inspectable and translatable object trees; understand node types, parameter identity, visitors, compilation, and LINQ provider boundaries. intermediate 4 min · from Expression trees c# Predict the output new What does this program print? Understand how C# programs execute through expressions, statements, control flow, and methods, with a reliable model for types and input boundaries. beginner 2 min · from C# fundamentals c# Predict the output new Which lines does this program print? Understand how C# programs execute through expressions, statements, control flow, and methods, with a reliable model for types and input boundaries. beginner 2 min · from C# fundamentals c# Review AI code new Review generated order summary Understand how C# programs execute through expressions, statements, control flow, and methods, with a reliable model for types and input boundaries. intermediate 6 min · from C# fundamentals c# Spot the bug new Spot the bug in the array sum Understand how C# programs execute through expressions, statements, control flow, and methods, with a reliable model for types and input boundaries. beginner 4 min · from C# fundamentals c# Quiz new What does var mean in var amount = 12.5m;? Understand how C# programs execute through expressions, statements, control flow, and methods, with a reliable model for types and input boundaries. beginner 1 min · from C# fundamentals c# Quiz new Can C# infer T in Create<T>() from assigning its result to Customer customer? Use type parameters to design reusable, type-safe C# APIs, with precise constraints, inference, variance, and runtime generic behavior. intermediate 1 min · from Generics c# Predict the output new What does this program print? Use type parameters to design reusable, type-safe C# APIs, with precise constraints, inference, variance, and runtime generic behavior. beginner 2 min · from Generics c# Predict the output new What values are printed by these generic static fields? Use type parameters to design reusable, type-safe C# APIs, with precise constraints, inference, variance, and runtime generic behavior. intermediate 2 min · from Generics c# Review AI code new Review generated token deduplicator Use type parameters to design reusable, type-safe C# APIs, with precise constraints, inference, variance, and runtime generic behavior. advanced 8 min · from Generics c# Spot the bug new Spot the bug in the generic search Use type parameters to design reusable, type-safe C# APIs, with precise constraints, inference, variance, and runtime generic behavior. intermediate 4 min · from Generics c# Quiz new Given Dog : Animal, which assignment is valid because of generic variance? Use type parameters to design reusable, type-safe C# APIs, with precise constraints, inference, variance, and runtime generic behavior. intermediate 1 min · from Generics c# Quiz new What does AsEnumerable do in an IQueryable pipeline? Compose type-safe queries with LINQ; understand deferred execution, materialization, operator contracts, ordering, and provider boundaries. advanced 1 min · from LINQ c# Quiz new A validated email must identify exactly one account. Which operator best enforces that re… Compose type-safe queries with LINQ; understand deferred execution, materialization, operator contracts, ordering, and provider boundaries. beginner 1 min · from LINQ c# Predict the output new What does this program print after the source list changes? Compose type-safe queries with LINQ; understand deferred execution, materialization, operator contracts, ordering, and provider boundaries. beginner 2 min · from LINQ c# Predict the output new Which name order does this program print? Compose type-safe queries with LINQ; understand deferred execution, materialization, operator contracts, ordering, and provider boundaries. intermediate 2 min · from LINQ c# Review AI code new Review a generated customer totals query Compose type-safe queries with LINQ; understand deferred execution, materialization, operator contracts, ordering, and provider boundaries. advanced 6 min · from LINQ c# Spot the bug new Spot the bug in report enumeration Compose type-safe queries with LINQ; understand deferred execution, materialization, operator contracts, ordering, and provider boundaries. intermediate 4 min · from LINQ c# Quiz new Why can an arbitrary IEnumerable<string> not be matched directly with ["run", var file]? Match runtime types and data shapes safely in C#, with explicit ordering, null handling, exhaustiveness, and list-pattern boundaries. intermediate 1 min · from Pattern matching c# Predict the output new What does this program print? Match runtime types and data shapes safely in C#, with explicit ordering, null handling, exhaustiveness, and list-pattern boundaries. intermediate 2 min · from Pattern matching c# Predict the output new Which label does this three-element command produce? Match runtime types and data shapes safely in C#, with explicit ordering, null handling, exhaustiveness, and list-pattern boundaries. intermediate 2 min · from Pattern matching c# Review AI code new Review a generated command router Match runtime types and data shapes safely in C#, with explicit ordering, null handling, exhaustiveness, and list-pattern boundaries. advanced 8 min · from Pattern matching c# Spot the bug new Spot the bug in the age classifier Match runtime types and data shapes safely in C#, with explicit ordering, null handling, exhaustiveness, and list-pattern boundaries. beginner 4 min · from Pattern matching c# Quiz new What does value is string text establish when the match succeeds? Match runtime types and data shapes safely in C#, with explicit ordering, null handling, exhaustiveness, and list-pattern boundaries. beginner 1 min · from Pattern matching c# Quiz new Which statement about `public required string Name { get; init; }` is correct? Understand C# properties, accessors, auto-properties, init, and required, including validation, mutability, and ownership traps. intermediate 1 min · from Properties c# Predict the output new What does this program print? Understand C# properties, accessors, auto-properties, init, and required, including validation, mutability, and ownership traps. beginner 2 min · from Properties c# Review AI code new Review generated user profile Understand C# properties, accessors, auto-properties, init, and required, including validation, mutability, and ownership traps. intermediate 6 min · from Properties c# Spot the bug new Spot the bug in team membership Understand C# properties, accessors, auto-properties, init, and required, including validation, mutability, and ownership traps. intermediate 4 min · from Properties c# Spot the bug new Spot the bug in the Name setter Understand C# properties, accessors, auto-properties, init, and required, including validation, mutability, and ownership traps. beginner 4 min · from Properties c# Quiz new Why does a base record not compare equal to a derived record with the same shared values? Model data with C# record classes and record structs while keeping equality, copying, mutability, and inheritance behavior explicit. intermediate 1 min · from Records c# Predict the output new What does this program print? Model data with C# record classes and record structs while keeping equality, copying, mutability, and inheritance behavior explicit. beginner 2 min · from Records c# Predict the output new What does this shallow-copy example print? Model data with C# record classes and record structs while keeping equality, copying, mutability, and inheritance behavior explicit. intermediate 2 min · from Records c# Quiz new Which statement about positional record structs is correct? Model data with C# record classes and record structs while keeping equality, copying, mutability, and inheritance behavior explicit. intermediate 1 min · from Records c# Review AI code new Review a generated search cache key Model data with C# record classes and record structs while keeping equality, copying, mutability, and inheritance behavior explicit. advanced 10 min · from Records c# Spot the bug new Spot the bug in the record cache key Model data with C# record classes and record structs while keeping equality, copying, mutability, and inheritance behavior explicit. intermediate 4 min · from Records c# Quiz new A scanner needs recorded attribute arguments but must not instantiate the attribute. Whic… Inspect types and members at runtime, select overloads precisely, invoke code safely, and handle attributes, trimming, and Native AOT boundaries. intermediate 1 min · from Reflection c# Predict the output new What two type names does this program print? Inspect types and members at runtime, select overloads precisely, invoke code safely, and handle attributes, trimming, and Native AOT boundaries. beginner 2 min · from Reflection c# Predict the output new How many properties does this lookup print? Inspect types and members at runtime, select overloads precisely, invoke code safely, and handle attributes, trimming, and Native AOT boundaries. beginner 2 min · from Reflection c# Quiz new A mapper may write only properties with public setters. Which test expresses that contrac… Inspect types and members at runtime, select overloads precisely, invoke code safely, and handle attributes, trimming, and Native AOT boundaries. intermediate 1 min · from Reflection c# Review AI code new Review a generated reflection command router Inspect types and members at runtime, select overloads precisely, invoke code safely, and handle attributes, trimming, and Native AOT boundaries. advanced 6 min · from Reflection c# Spot the bug new Spot the bug in overload lookup Inspect types and members at runtime, select overloads precisely, invoke code safely, and handle attributes, trimming, and Native AOT boundaries. intermediate 4 min · from Reflection c# Quiz new Generator A emits a type that generator B wants to inspect. What is safe for ordinary sou… Add C# source during compilation and design incremental pipelines, semantic matching, deterministic output, diagnostics, and reliable generator tests. advanced 1 min · from Source generators c# Quiz new Which pipeline model gives Roslyn the clearest stable value boundary? Add C# source during compilation and design incremental pipelines, semantic matching, deterministic output, diagnostics, and reliable generator tests. intermediate 1 min · from Source generators c# Predict the output new What does this program print when the platform source generator is available? Add C# source during compilation and design incremental pipelines, semantic matching, deterministic output, diagnostics, and reliable generator tests. beginner 2 min · from Source generators c# Review AI code new Review a generated route source generator Add C# source during compilation and design incremental pipelines, semantic matching, deterministic output, diagnostics, and reliable generator tests. advanced 6 min · from Source generators c# Spot the bug new Spot the bug in the attribute filter Add C# source during compilation and design incremental pipelines, semantic matching, deterministic output, diagnostics, and reliable generator tests. intermediate 4 min · from Source generators c# Quiz new A method stores caller data, awaits I/O, then reads the data. Which parameter best expres… Use Span<T> and Memory<T> for contiguous memory views while keeping slicing, async boundaries, ownership, and stack allocation explicit. intermediate 1 min · from Span<T> and Memory<T> c# Predict the output new What does the read-only view print after the variable is rebound? Use Span<T> and Memory<T> for contiguous memory views while keeping slicing, async boundaries, ownership, and stack allocation explicit. intermediate 2 min · from Span<T> and Memory<T> c# Predict the output new What does this program print after writing through the slice? Use Span<T> and Memory<T> for contiguous memory views while keeping slicing, async boundaries, ownership, and stack allocation explicit. beginner 2 min · from Span<T> and Memory<T> c# Review AI code new Review a generated pooled frame reader Use Span<T> and Memory<T> for contiguous memory views while keeping slicing, async boundaries, ownership, and stack allocation explicit. advanced 10 min · from Span<T> and Memory<T> c# Spot the bug new Spot the bug in pooled memory Use Span<T> and Memory<T> for contiguous memory views while keeping slicing, async boundaries, ownership, and stack allocation explicit. intermediate 4 min · from Span<T> and Memory<T>