Questions

C# questions

Choose a question page, learn the concept, then test your understanding with a quiz.

AddTransient vs AddScoped vs AddSingleton in ASP.NET Core Dependency Injection

Learn the differences between AddTransient, AddScoped, and AddSingleton in ASP.NET Core DI with examples and practical usage.

csharpasp.net-core.net-core

C# Type Checking Explained: typeof vs GetType() vs is

Learn when to use typeof, GetType(), and is in C#. Understand exact type checks, inheritance, and safe type testing clearly.

csharptypestypeofgettype

C# Version Numbers Explained: C# vs .NET Framework and Why “C# 3.5” Is Incorrect

Learn the correct C# version numbers, how they map to .NET releases, and why terms like C# 3.5 are inaccurate and confusing.

csharp.netvisual-studio.net-core

C# const vs static readonly: When to Use Each

Learn the difference between const and static readonly in C#, when each is appropriate, and whether properties are a better choice.

csharpconstants

C# foreach Closure Behavior Explained: Why Loop Variables Were Reused

Learn why C# foreach loop variables once caused closure bugs, how the compiler handled scope, and what changed in newer C# versions.

csharpforeachlambdascope

Call a Generic Method with a Runtime Type in C#

Learn how to call a generic method using a Type variable in C# with reflection, MakeGenericMethod, and practical examples.

csharp.netgenericsreflection

Calling Async Methods from Synchronous Code in C#

Learn how to call async methods from synchronous code in C#, when it is safe, common pitfalls, and better alternatives.

csharpasynchronousasync-awaitsynchronous

Case-Insensitive String.Contains in C#

Learn how to make string.Contains case-insensitive in C#, including StringComparison, examples, pitfalls, and real-world usage.

csharpstringcontainscase-insensitive

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.

csharp.neturl

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.

csharp.netconstantsreadonly

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.

csharparrayshex

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.

csharp.netexcelfile-io

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.

csharp.netclonedeep-copy

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.

csharp.netclrtry-catch

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.

csharpooppropertiesfield

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.

csharpasp.net.netvisual-studio

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.

csharp.netrandom

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.

csharpreflectionproperties

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.

csharpforeach

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.

csharp.netasynchronousasync-await

Page 1 of 4 - 62 questions

PreviousNext