Questions
C# questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Set the Authorization Header with WinRT HttpClient and OAuth Tokens
Learn how to set OAuth Bearer Authorization headers with WinRT HttpClient, including the correct header class and secure usage patterns.
Split a String by Another String in C#
Learn how to split strings using multi-character delimiters in C# with String.Split, StringSplitOptions, examples, pitfalls, and a mini project.
String Representation of an Enum in C#
Learn how to get string values from enums in C#, when ToString() is enough, and when to use attributes like Description or custom mapping.
String to byte[] in C#: Why Encoding Matters in .NET
Learn why C# strings need an encoding to become byte arrays, how .NET stores strings, and how to get consistent bytes safely.
String vs string in C#: What's the Difference?
Learn the difference between String and string in C#, when they are equivalent, and which style to use in real code.
Understanding Visual Studio Breakpoints and PDB Symbols in C#
Learn why Visual Studio says no symbols have been loaded, what PDB files do, and how to fix C# breakpoints that will not be hit.
Useful C# and .NET Attributes: Namespaces and Examples
Learn commonly used C# and .NET attributes, their namespaces, and practical examples for validation, serialization, metadata, and tooling.
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.
Volatile, Interlocked, and lock in C#: Thread-Safe Counters
Learn when to use volatile, Interlocked, and lock in C# for thread-safe counters, atomic updates, memory visibility, and shared state.
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.
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.
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.
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.
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.
Why C# Random Generates Repeated Numbers in a Loop
Learn why creating a new C# Random inside a fast loop can repeat values, how debugger timing changes results, and how to generate random bytes correctly.
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.
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.
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.
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.
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.