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

Best Way to Repeat a Character in C#: Building Repeated Strings Efficiently

Learn the best way to repeat a character in C#, compare StringBuilder, string concatenation, and simpler built-in options.

csharp.netstring

C# Access Modifiers and static: public, private, protected, and Defaults

Learn how C# public, private, protected, and default access control visibility, and how static differs from instance members.

csharp.netasp.netaccess-modifiers

C# Array Initialization Syntaxes Explained

Learn all common C# array initialization syntaxes with examples, rules, comparisons, and mistakes beginners often make.

csharparrayssyntaxarray-initialization

C# Auto-Implemented Properties: Understanding { get; set; }

Learn what C# { get; set; } properties mean, how getters and setters work, and how ASP.NET MVC models use them safely.

csharpproperties

C# Class Member Order: Organizing Fields, Properties, Constructors, and Methods

Learn practical C# class member ordering conventions for fields, properties, constructors, and methods, and how to enforce a team style consistently.

csharp.netcode-cleanupcode-structure

C# Dictionary Collection Initializers and Language Version Support

Learn why C# dictionary collection initializers fail in older language versions and how to initialize dictionaries using compatible syntax.

csharpdictionary

C# Direct Casting vs as Operator vs ToString()

Learn the differences between direct casts, the C# as operator, and ToString(), including failure behavior and when to use each safely.

csharpcasting

C# Empty Strings: string.Empty, String.Empty, or ""?

Learn the difference between string.Empty, String.Empty, and "" in C#, including style guidance, equality, null safety, and practical examples.

csharp.netstringinitialization

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# Verbatim Strings: What @ Before a String Means

Learn what the @ symbol before a C# string means, how verbatim strings handle escapes, quotes, paths, and multiline text.

csharp.netstringverbatim-string

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# async Task vs async void: When to Use Each

Learn when C# async methods should return Task instead of void, how exceptions and awaiting work, and why Task.Delay is preferred.

csharpasynchronous.net-4.5

C# break vs continue in Loops: Differences and Examples

Learn the difference between break and continue in C# loops, with foreach examples, execution traces, common mistakes, and practical patterns.

csharploopsbreakenumeration

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

C# ref vs out: What’s the Difference and When Should You Use Each?

Learn the difference between C# ref and out parameters, when to use each, and how they affect method calls, assignment, and intent.

csharpreferencekeyword

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

Page 1 of 9 - 162 questions

PreviousNext