Questions
C# questions
Choose a question page, learn the concept, then test your understanding with a quiz.
LINQ Aggregate in C#: A Clear Guide with Examples
Learn how C# LINQ Aggregate reduces a sequence to one value using an accumulator, seeds, practical examples, and common pitfalls.
LINQ Distinct Equality Comparers and DistinctBy in C#
Learn how C# LINQ Distinct uses IEqualityComparer and hash codes, with practical custom comparer, lambda adapter, and DistinctBy examples.
LINQ List Difference in C#: Find Items Not in Another List
Learn how to use LINQ in C# to find objects in one list that are absent from another list, with ID comparisons, HashSet, and Except examples.
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.
Multiple Switch Cases in C#: Grouping Case Labels
Learn how to group multiple case values in C# switch statements, use intentional fall-through, and use modern C# or patterns.
Partial Entity Updates in Entity Framework 5 with ASP.NET MVC
Learn how to update selected Entity Framework 5 properties in one SQL command using attached entities, view models, and IsModified.
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.
Proper Use of yield return in C#: Deferred Execution vs ToList()
Learn when to use yield return in C#, how it differs from ToList(), and why deferred execution matters with IEnumerable and database contexts.
Remove List Elements with LINQ in C#
Learn how to safely remove matching elements from a C# List<T>, why LINQ queries should not modify their source, and when to use RemoveAll.
Remove Non-Alphanumeric Characters Except Dashes and Spaces in JavaScript
Learn how to use JavaScript regular expressions to remove unwanted characters while preserving letters, numbers, dashes, and spaces.
Rename a File in C#: File.Move and Safe Rename Patterns
Learn how to rename files in C# with File.Move, including paths, overwriting behavior, validation, error handling, and practical examples.
Retrieve an Inserted Entity ID with Entity Framework in C#
Learn how Entity Framework retrieves database-generated identity IDs after SaveChanges, why identity gaps occur, and how to use keys safely.
Run Async Task<T> Methods Synchronously in C# Without Deadlocks
Learn why blocking async Task<T> code can deadlock in C# UI apps, when GetAwaiter().GetResult() is valid, and safer async patterns.
Run Command Prompt Commands from C# with ProcessStartInfo
Learn how to run Command Prompt commands from C# using ProcessStartInfo, capture output, pass arguments safely, and copy binary files.
SQL Server to C# Data Type Mapping Guide
Learn the common SQL Server to C# data type mappings, including numbers, dates, strings, binary data, GUIDs, XML, and nullable values.
Save a Stream to a File in C#: Binary and Text Streams
Learn how to save a C# Stream to disk safely, why StreamReader breaks binary files, and when encoding matters for files and SQL Server.
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.
Sending Email with Gmail in .NET: SMTP Basics, Setup, and Safer Alternatives
Learn how to send email from .NET using Gmail, how SMTP works, common pitfalls, and safer approaches for real applications.
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.