Questions

C# questions

Choose a question page, learn the concept, then test your understanding with a quiz.

Using Directives Inside vs Outside a Namespace in C#

Learn why C# using directives can be placed inside or outside a namespace, how scope changes, and what StyleCop is enforcing.

csharp.netnamespacesstylecop

What Is a NullReferenceException in C# and How Do You Fix It?

Learn what a NullReferenceException means in C#, why it happens, and practical ways to prevent and fix null reference errors.

csharp.netvb.netnull

What the ?? Operator Means in C#

Learn what the ?? null-coalescing operator means in C#, how it works, when to use it, and how it differs from the ternary operator.

csharpnull-coalescing-operator

What the [Flags] Enum Attribute Means in C#

Learn what the [Flags] enum attribute does in C#, how bit flags work, and how to combine enum values safely with clear examples.

csharpenumsflags

What the yield Keyword Does in C#: Iterators and Lazy Enumeration

Learn what the C# yield keyword does, how yield return works, and why it is used to build lazy iterators and enumerable sequences.

csharpyield

When to Use struct vs class in C#: Value Types Explained

Learn when to use struct instead of class in C#, including value semantics, size guidelines, immutability, and practical examples.

csharpstruct

Why Calling a Virtual Member in a Constructor Is Risky in C#

Learn why calling a virtual member inside a constructor is risky in C#, what can go wrong, and safer alternatives to use instead.

csharpconstructorwarningsresharper

Why Dictionary Is Preferred Over Hashtable in C#

Learn why Dictionary<TKey, TValue> is usually preferred over Hashtable in C#, including type safety, performance, syntax, and real usage.

csharp.netvb.netdata-structures

Why Inheriting from List<T> Is Usually a Bad Idea in C#

Learn when to inherit from List<T> in C#, why composition is usually better, and how to model custom collections safely.

csharp.netlistoop

Why Override GetHashCode When Overriding Equals in C#

Learn why GetHashCode must match Equals in C#, how hash-based collections work, and how to implement both methods correctly.

csharpoverridinghashcode

Why \d Can Be Slower Than [0-9] in C# Regex

Learn why \d may be slower than [0-9] in C# regex, how digit classes work, and when to use \d, [0-9], or explicit character sets.

csharpregexperformance

decimal vs double in C#: When to Use Each Type

Learn the difference between decimal and double in C#, when to use each, and which type is best for money and precision-sensitive calculations.

csharpdoubledecimalprecision

Page 6 of 6 - 112 questions