Questions

C# questions

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

Func vs Action vs Predicate in C#: Differences, Uses, and Examples

Learn when to use Func, Action, and Predicate in C# with simple examples, comparisons, and practical patterns for beginners.

csharpdelegatesactionfunc

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 Class Properties in JavaScript: Object Reflection Guide

Learn how to list JavaScript class properties using Object.keys, Object.getOwnPropertyNames, prototypes, and reflection APIs.

csharp.netreflectionproperties

Get a Generic Type Parameter at Runtime in C# with typeof(T)

Learn how to determine a generic type parameter at runtime in C# using typeof(T), without needing an item in a List<T>.

csharp.netgenerics

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

Handling Multiple Submit Buttons in ASP.NET MVC

Learn how multiple submit buttons work in ASP.NET MVC forms, including name/value routing, validation, guard clauses, and practical C# examples.

csharphtmlasp.net-mvchttp-post

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

How to Assert Exceptions in MSTest (C#)

Learn how to verify exceptions in MSTest using Assert.ThrowsException, ExpectedException, and practical C# testing patterns.

csharpunit-testingmstestassert

How to Calculate Age from a DateTime Birthday in C#

Learn how to calculate a person's age in years from a DateTime birthday in C# with clear logic, examples, pitfalls, and best practices.

csharp.netdatetime

How to Calculate Relative Time in C#

Learn how to display relative time in C# from a DateTime value, such as '2 hours ago', '3 days ago', or 'a month ago'.

csharpdatetimetimerelative-time-span

How to Calculate the Difference Between Two Dates in C#

Learn how to calculate the number of days between two dates in C# using DateTime and TimeSpan with clear examples and common pitfalls.

csharpdate

How to Call One Constructor from Another in C#

Learn constructor chaining in C#: call one constructor from another, avoid duplication, and initialize readonly fields correctly.

csharpconstructor

How to Call a Base Class Constructor in C#

Learn how to call a base class constructor in C#, including Exception examples, syntax, common mistakes, and practical usage.

csharp.netinheritanceconstructor

How to Cast an int to an Enum in C#

Learn how to cast an int to an enum in C#, when it works, how to validate values, and common mistakes to avoid.

csharpenumscastinginteger

How to Catch Multiple Exceptions at Once in C#

Learn how to catch multiple exceptions in C#, avoid repetitive catch blocks, and choose cleaner patterns like exception filters and TryParse.

csharp.netexception

How to Check If a String Is a Number in JavaScript

Learn how to check whether a string contains a valid number in JavaScript, with examples, pitfalls, and practical patterns.

csharpstringparsingisnumeric

How to Check Whether a File Is in Use in C#

Learn how to detect file locks in C#, why race conditions happen, and how to safely access files with retries and proper file sharing.

csharp.netfilefile-io

How to Constrain a Generic Type to Enum in C#

Learn how to constrain generic methods to enum types in C#, parse enum values safely, and provide defaults with case-insensitive matching.

csharpgenericsenumsgeneric-constraints

How to Convert a Byte Array to a String in C#

Learn how to convert a byte array to a string in C#, including encoding, BinaryWriter behavior, and common mistakes with UTF-8 bytes.

csharparraysbinaryreader

Page 4 of 9 - 162 questions