Questions
C# questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Class Library (.NET Core) vs .NET Standard in C#: Differences, Use Cases, and When to Choose Each
Learn the difference between .NET Core and .NET Standard class libraries, why both exist, and when to use each in C# projects.
Clean Up Excel COM Interop Objects in C#
Learn how to close Excel COM interop safely in C#, release objects in order, avoid hidden Excel.exe processes, and prevent COM reference leaks.
Clone a Generic List in C#: Shallow vs Deep Copy
Learn how to clone a C# List<T>, distinguish shallow and deep copies, and safely clone the objects stored in a generic list.
Collection Was Modified During Enumeration in C#: Why It Happens and How to Fix It
Learn why C# throws 'Collection was modified' during foreach, especially with Dictionary and multithreading, and how to fix it safely.
Combining URL Parts in C#: Uri and Safe URL Joining in .NET
Learn how to combine URL parts safely in C# using Uri instead of Path.Combine, with examples, pitfalls, and practical patterns.
Const vs Readonly in C#: What's the Difference and When to Use Each
Learn the difference between const and readonly in C#, when each is evaluated, and how to choose the right one in real code.
Convert Byte Arrays to Hex Strings in Java
Learn how to convert a byte array to a hexadecimal string and back in Java with clear examples, common mistakes, and practical use cases.
Convert Decimal to Double in C#: Explicit Numeric Conversions
Learn why C# requires an explicit decimal-to-double conversion, how to avoid integer division, and safely assign values to UI properties.
Convert List<string> to a Delimited String in C#
Learn how to convert a List<string> to a single delimited string in C# using string.Join, with examples, pitfalls, and real-world use cases.
Convert Unix Timestamp to DateTime in C#
Learn how to convert Unix timestamps to DateTime and back in C#, including UTC handling, examples, pitfalls, and best practices.
Convert a String to DateTime in C# with ParseExact
Learn to convert date strings to C# DateTime safely using DateTime.ParseExact and TryParseExact with custom format strings.
Convert a String to an Int in C# Safely
Learn how to convert TextBox text to an int in C# with int.TryParse, input validation, error handling, and safe database parameters.
Convert an Enum to a List in C#
Learn how to enumerate every declared enum value in C# with Enum.GetValues, convert the result to a List, and handle aliases safely.
Convert byte[] to Stream in C#: Using MemoryStream
Learn how to convert a byte array to a Stream in C# using MemoryStream, with examples, common mistakes, and practical use cases.
Converting Object to Byte Array and String in C#
Learn how to convert directory property values from object to byte[] or string in C#, and when to use Encoding.UTF8.GetString correctly.
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.