Questions
C# questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Count Character or Substring Occurrences in a String in C#
Learn how to count characters or substrings in a string in C# using Replace, loops, and regex with examples and common mistakes.
Create Excel Files in C# Without Microsoft Office Installed
Learn how to create .XLSX and .XLS files in C# without installing Microsoft Office using common libraries and practical examples.
Create a Comma-Separated String from IEnumerable<string> in C#
Learn the cleanest way to build comma-separated strings from IList<string> or IEnumerable<string> in C# with examples and common pitfalls.
Create a Folder If It Does Not Exist in C#
Learn how to check for a folder and create it if needed before saving uploaded files in C# using Directory.CreateDirectory.
DateTime vs DateTimeOffset in C#: Differences, Usage, and Best Practices
Learn the difference between DateTime and DateTimeOffset in C#, when to use each, and how to handle UTC, offsets, and time zones safely.
Deep Copy and Object Cloning in C#
Learn how deep copying and object cloning work in C#, with practical examples, pitfalls, and safe ways to duplicate objects.
Deserialize JSON into a C# dynamic Object
Learn how to deserialize JSON into a C# dynamic object, when to use it, its trade-offs, and practical examples with JSON libraries.
Does C# Have Extension Properties? Understanding Extension Methods and Alternatives
Learn whether C# supports extension properties, why it does not, and how to use extension methods or wrappers instead.
Does try-catch Make C# Code Faster? Understanding Benchmarking, JIT Optimization, and Microbenchmarks
Learn why try-catch can appear faster in C#, and how JIT behavior, CPU timing, and poor microbenchmarks can mislead results.
Expression<Func<T>> vs Func<T> in C#: What’s the Difference and When to Use Each?
Learn when to use Expression<Func<T>> instead of Func<T> in C#, with clear examples, execution differences, and real-world LINQ usage.
Field vs Property in C#: What’s the Difference and When to Use Each
Learn the difference between fields and properties in C#, when to use each one, and how encapsulation affects real-world class design.
First vs FirstOrDefault vs Take(1) in LINQ with C#
Learn when to use First, FirstOrDefault, and Take(1) in LINQ with C#. Understand exceptions, defaults, and practical usage patterns.
Fixing "Could Not Find ... bin\roslyn\csc.exe" in ASP.NET MVC
Learn why ASP.NET MVC looks for bin\roslyn\csc.exe, what Roslyn packages do, and how to fix this missing compiler error safely.
Fixing Assembly Manifest Mismatch in C# (.NET): The Located Assembly's Manifest Definition Does Not Match the Assembly Reference
Learn why C# assembly manifest mismatch errors happen, how to find old DLL references, and how to fix version conflicts in .NET projects.
Func vs Action vs Predicate in C#: Differences, Uses, and Examples
Learn when to use Func, Action, and Predicate in C# with simple examples, comparisons, and practical patterns for beginners.
Generate Random Alphanumeric Strings in C#
Learn how to generate random 8-character alphanumeric strings in C# with clear examples, secure options, and common mistakes to avoid.
Get a Property Value from a String Using Reflection in C#
Learn how to read a property value from a string using reflection in C#, including syntax, examples, common mistakes, and safe usage patterns.
Get the Current Index in a foreach Loop in C#
Learn how to get the current index during a foreach loop in C#, when to use for instead, and common beginner-friendly patterns.
How and When to Use async and await in C#
Learn how async and await work in C#, when code runs, what await actually pauses, and why async does not automatically create threads.
How to Assert Exceptions in MSTest (C#)
Learn how to verify exceptions in MSTest using Assert.ThrowsException, ExpectedException, and practical C# testing patterns.