Questions
C# questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Update the GUI from Another Thread in C# WinForms
Learn the safe way to update a WinForms Label from another thread in C#, using Invoke, BeginInvoke, and thread-safe UI patterns.
How to Use GroupBy in LINQ to Group Objects and Collect Values in C#
Learn how to use LINQ GroupBy in C# to group people by PersonID and collect related values like car names into lists.
How to Use LINQ Distinct by Property in C#
Learn how to get distinct objects by one or more properties in C# using LINQ, equality comparers, GroupBy, and modern DistinctBy examples.
IQueryable vs IEnumerable in C#: Differences, Deferred Execution, and When to Use Each
Learn the difference between IQueryable and IEnumerable in C#, how deferred execution works, and when to return each in real applications.
Lesser-Known C# Features and Language Tricks for Everyday Development
Learn hidden but useful C# features like yield, var, using, nullable types, attributes, and generics with practical examples.
Multiline String Literals in C#: Verbatim and Raw String Syntax
Learn how to create multiline string literals in C# using verbatim and raw strings, with examples, comparisons, mistakes, and practice.
Proper Use of IDisposable in C#: Managed vs Unmanaged Resources
Learn when to use IDisposable in C#, what Dispose should clean up, and whether clearing managed collections frees memory faster.
Select vs SelectMany in LINQ and LINQ to SQL
Learn the difference between Select and SelectMany in LINQ to SQL with clear C# examples, execution steps, mistakes, and practical use cases.
Serialize Enums as Strings in JSON with JavaScriptSerializer and .NET
Learn how enum JSON serialization works in JavaScriptSerializer, why enums become numbers, and how to output enum names as strings in .NET.
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.
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.
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.
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 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.