Skip to content

C#, .NET and SQL Server Interview Questions

This page collects every interview question topic on MakeMyCodes in one place, grouped by subject. Each topic is a complete article: it explains the concept in simple words, shows working code with real output, compares the options side by side, and ends with the follow-up questions interviewers usually ask next.

The questions are the ones that come up again and again in interviews for .NET developer roles, from freshers to developers with five or more years of experience. Interviewers rarely stop at a definition; they ask "what is the output?", "when would you use it?" and "where did you use it in your project?". The articles are written to help you answer those deeper questions with confidence.

C# language

TopicWhat you will learn
var vs dynamicCompile-time vs runtime typing, the errors each produces, and var vs object vs dynamic
readonly vs const vs staticWhen each value is fixed and where it can be assigned
Boxing and unboxingWhat happens in memory, InvalidCastException, hidden boxing and its measured performance cost
Parameter passing: ref, out, in, paramsValue vs reference passing, overloading rules and 10 "what is the output" puzzles
IEnumerable vs ListHow each is implemented, and when to use IEnumerable or List
Extension methodsWhat extension methods are and how to write one
Constructors in C#What constructors are and the types of constructors in C#
Reverse a string in C#Several ways to solve a classic coding question, and which one to use

Object-oriented design

TopicWhat you will learn
Abstract vs sealed classOpposite purposes, when to use each, and why a class can't be both
Sealed vs static classHow the two class modifiers differ in inheritance and instances
Static class vs singletonA keyword vs a design pattern, and when to use each
Dispose vs FinalizeReleasing resources deterministically vs relying on the garbage collector
SOLID principles28 questions on SRP, OCP, LSP, ISP and DIP, with scenario-based answers

.NET and ASP.NET Core

TopicWhat you will learn
.NET Framework vs .NET CoreHistory, 15-point comparison, advantages, disadvantages and migration
ViewBag vs ViewData vs TempDataLifetimes, redirects, Peek and Keep, and when to use a ViewModel instead
In-memory vs distributed cachingThe two caching approaches and when each fits
Application performanceDo's and don'ts for faster .NET applications
Application securityDo's and don'ts for securing .NET applications

SQL Server

TopicWhat you will learn
DELETE vs TRUNCATELogging, identity reset, triggers, rollback and permissions, with real output
Find the Nth highest salarySeveral solutions compared, including ties and departments
Stored procedure vs functionThe differences between the two and where each can be used
Temp table vs CTEHow they differ and when to choose each
Date functions in SQL ServerThe date and time functions you use most often

Also useful for interviews

These tutorials are not written as question lists, but they cover topics interviewers ask about all the time, and each one ends with interview questions:

How to prepare for a .NET interview

  1. Understand, don't memorise. For every topic, be able to explain why it works the way it does. "TRUNCATE is faster because it deallocates pages instead of logging each row" is a much stronger answer than "TRUNCATE is faster".
  2. Run the code yourself. Copy the examples into a console app or SQL Server Management Studio and change them. Output questions ("what does this print?") are easy once you have seen the behaviour with your own eyes.
  3. Prepare a project example for each big topic. For SOLID, caching, dependency injection or async, have one short story ready: "In our order system we used..." Interviewers trust real experience more than definitions.
  4. Learn the comparisons. Most questions are "X vs Y". Each article has a comparison table; reading those tables the day before an interview is excellent revision.
  5. Know the trade-offs. Senior interviews ask "when would you not use it?". Every topic has a cost: performance, complexity or testability.
  6. Practise SQL by hand. Write the Nth highest salary, joins and GROUP BY queries without help, because many interviews include a live SQL task.

Found a question that isn't covered, or an answer you think could be better? Write to contactus@makemycodes.com. New topics are added regularly.