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.

csharprestoauthwindows-runtime

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.

csharp.netstringsplit

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.

csharpenums

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.

csharp.netstringcharacter-encoding

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.

csharp.netstringtypes

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.

csharp.netdebuggingbreakpoints

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.

csharp.net.net-attributes

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

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.

csharpmultithreadinglockingvolatile

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 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.

csharprandom

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

Page 8 of 9 - 162 questions