Skip to content
Preptima

Top 4 Csharp Interview Questions

Browse 4 real-world technical and behavioral interview questions about Csharp. Review scenarios, edge cases, and architectural best practices.

A client disconnects but your server keeps working on their request. How does cancellation actually propagate in .NET?

A CancellationToken in C# is cooperative cancellation, not a thread abort. Pass it through async calls, check it around long CPU loops, and define whether cancelled work leaves durable side effects behind.

mediumconcept

When would you make a type a record, a struct, or a class? What does each choose for you?

A class gives reference identity, a struct gives value semantics and lives inline, and a record is a class with value-based equality and a copy-with-changes syntax generated for you. The decision is about identity and copying cost, not about which one is newest.

mediumconcept

What is the difference between a value type and a reference type in C#, and what do nullable reference types guarantee?

C# value types store data directly and copy on assignment, while reference types store references to heap objects. Nullable reference types are compile-time flow-analysis warnings, not runtime null guarantees. It also connects structs to the point an interviewer is testing.

mediumconcept

You build a LINQ query, then change the list it came from, then enumerate it. What do you get?

The results reflect the list and the captured variables as they are at enumeration time, not at query construction, because a LINQ-to-objects query is an iterator holding references rather than a snapshot. Enumerating it twice runs the whole chain twice. It also connects deferred execution to the point an interviewer is testing.

mediumcoding