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.

csharp.netlinqaggregate

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.

csharpc#-3.0lambdaextension-methods

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.

csharplinq.net-3.5

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.

csharphidden-features

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.

csharpstringshorthand

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.

csharpswitch-statement

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.

csharpasp.net-mvc-3entity-framework-5

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.

csharp.netgarbage-collectionidisposable

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.

csharpyield-return

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.

csharp.netlinqlist

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.

csharpregex

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.

csharpfilerename

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.

csharpasp.netentity-framework

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.

csharpasynchronousc#-5.0async-await

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.

csharp.netcommand-linecommand

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.

csharp.netsql-server

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.

csharp.netstream

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.

csharplinq-to-sqllinq

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.

csharp.netemailsmtp

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.

csharpasp.netjsonenums

Page 7 of 9 - 162 questions