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.
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.
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.
C# Array Initialization Syntaxes Explained
Learn all common C# array initialization syntaxes with examples, rules, comparisons, and mistakes beginners often make.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Case-Insensitive String.Contains in C#
Learn how to make string.Contains case-insensitive in C#, including StringComparison, examples, pitfalls, and real-world usage.
Page 1 of 9 - 162 questions