A database query is slow. How would you troubleshoot it?
Start by measuring the query and inspecting the generated SQL. Determine whether the delay is in the application, network, connection pool, database execution, or result materialization.
C# interview questions covering senior .net practical scenarios.
Open a question for the full answer, code and interview guidance.
Start by measuring the query and inspecting the generated SQL. Determine whether the delay is in the application, network, connection pool, database execution, or result materialization.
First use memory metrics, dumps, traces, and a profiler to determine what objects are consuming memory and whether usage is expected, retained, or leaking through references.
Use centralized exception handling instead of duplicating broad try/catch blocks in every controller.
Application-level existence checks alone are insufficient because two concurrent requests can both pass the check before either inserts a row.
Avoid loading the complete dataset into memory with an unrestricted ToList.
Prefer established caching abstractions such as IMemoryCache instead of implementing a cache from scratch.
Use HttpClient through IHttpClientFactory or another managed client strategy instead of creating and disposing a new HttpClient for every request.
Secrets should not be hard-coded in C# files or committed to source control.
Start with clear module boundaries, meaningful naming, consistent coding conventions, and classes with focused responsibilities.
A production C# application should combine correct software design, security, performance, reliability, observability, and maintainability.