📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

1325 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

Phase 27 — AI and Modern Developer Productivity

Using AI well as a senior .NET engineer: AI-assisted development and its risks, building AI features in .NET with Azure OpenAI, Microsoft.Extensions.AI and Semantic Kernel (embeddings, vector search, RAG, function calling), and agents and MCP, with safety, prompt injection and data-leakage controls.

  1. How do you prompt an AI coding assistant well for code? What context, constraints and examples do you give it, how do you ask for tests and edge cases, and how do you iterate when the first answer is wrong?

    Prompting AI assistants for code: goal, context, constraints and examples, instruction files, asking for edge cases and tests first, decomposing work, and iterating on concrete failures.

    Intermediate Theory AI-Assisted Development Β· πŸ”— 2 follow-ups
  2. What are the security risks of AI-generated code, such as insecure patterns, hallucinated packages, licence issues and secrets leaking into prompts, and how do you control them in a .NET team?

    Security risks of AI-generated code and AI coding tools: insecure patterns from training data, hallucinated packages and slopsquatting, licence exposure, secrets and personal data in prompts, poisoned instruction files, and the .NET controls for each.

    Mid-Level Security AI-Assisted Development Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  3. How do AI coding assistants such as GitHub Copilot actually work? Explain the LLM underneath, what context it sees, the difference between inline completion, chat and agent mode, and what these tools are good and bad at for a .NET developer.

    How AI coding assistants work: next-token prediction by an LLM, the context window and what the IDE sends, completion vs chat vs agent mode vs cloud coding agent, and their strengths and limits.

    Junior Theory AI-Assisted Development Β· πŸ”— 2 follow-ups
  4. How do you use AI for code review, test generation and documentation? Where does it genuinely save time, where does it waste it, and how do you check its output before trusting it?

    Using AI assistants for code review, unit test generation and documentation: where they help, where they mislead, and how to verify AI tests (mutation testing, breaking the code), AI review comments and generated docs.

    Mid-Level Theory AI-Assisted Development Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  5. How would you introduce AI coding tools to a .NET team? Talk me through the guidelines you'd set, what must still be reviewed by a human, how you'd handle sceptics and over-enthusiasts, and how you'd measure whether it actually helped.

    Leading an AI-tools rollout: pilot, usage and data guidelines, human review rules, training, handling different attitudes in the team, and measuring impact with delivery and quality metrics rather than acceptance rates.

    Senior Behavioral AI-Assisted Development Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  6. Code review: an AI coding agent opened a PR adding a CSV price-import endpoint to an ASP.NET Core API. It compiles, CI is green and the agent's own tests pass, but it pins an old Newtonsoft.Json version and has subtle bugs. Walk me through what you find, how you rank it, and how you close the review.

    Reviewing an AI-generated pull request: missing authorisation, fire-and-forget work, culture-dependent parsing, partial writes, a vulnerable pinned dependency and self-confirming tests, ranked by severity with a rewrite and review-closing policy.

    Senior CodeReview AI-Assisted Development Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  7. How do you keep the cost of an LLM feature under control in production? Cover model choice, prompt and history trimming, caching, output caps and budgets per user or tenant.
    Beginner Theory .NET and AI
  8. Why does an LLM sometimes give confident but wrong answers (hallucination), and what can a .NET developer do to reduce it?
    Beginner Theory .NET and AI
  9. How do you measure retrieval quality for a search or RAG feature? Explain hit rate, recall@k, MRR and nDCG, and how you build the labelled test set.
    Intermediate Theory .NET and AI
  10. When would you use hybrid search with a reranker instead of pure vector search, and how does reciprocal rank fusion combine the results?
    Intermediate Theory .NET and AI
  11. When should you use structured output (a JSON schema response) instead of tool calling, and how do you validate the result in .NET?
    Mid-Level Coding .NET and AI
  12. What is the difference between an AI agent and a workflow that calls an LLM at fixed steps, and how do you decide which one a feature needs?
    Mid-Level Theory .NET and AI
  13. You're a .NET developer about to call an LLM for the first time. What are tokens, the context window, temperature and a chat completion, and how do they drive cost and latency?

    LLM basics for a .NET developer: tokens and tokenisation, the context window, temperature and sampling, the chat completions message model (system, user, assistant), statelessness, and how tokens drive cost and latency.

    Beginner Theory .NET and AI Β· πŸ”— 2 follow-ups
  14. Show me how you'd call Azure OpenAI from an ASP.NET Core API using Microsoft.Extensions.AI. How do you register IChatClient in DI, authenticate without keys, stream the reply to the browser, and handle timeouts and throttling?

    Calling Azure OpenAI from ASP.NET Core with Microsoft.Extensions.AI: AzureOpenAIClient with DefaultAzureCredential and managed identity, AddChatClient with the ChatClientBuilder pipeline, streaming with GetStreamingResponseAsync and IAsyncEnumerable or server-sent events, cancellation, and 429 handling.

    Junior Coding .NET and AI Β· πŸ”— 2 follow-ups
  15. What is an embedding, and how does vector search work? Explain similarity measures, why and how you chunk documents, and how you'd choose between Azure AI Search, SQL Server 2025's vector type, Cosmos DB and pgvector for a .NET app.

    Embeddings and vector search: what an embedding vector represents, cosine similarity and dot product, exact versus approximate (HNSW) nearest-neighbour search, chunking strategies, hybrid search, IEmbeddingGenerator and Microsoft.Extensions.VectorData, and choosing a vector store.

    Intermediate Theory .NET and AI Β· πŸ”— 2 follow-ups
  16. Walk me through building a retrieval-augmented generation (RAG) pipeline in .NET. How do you ingest, chunk, embed and store documents, retrieve the right chunks for a question, ground the prompt, cite sources, and know that it works?

    End-to-end RAG in .NET: ingestion and chunking, embedding with IEmbeddingGenerator, storing with Microsoft.Extensions.VectorData, hybrid retrieval with permission filters, grounding prompts with numbered sources and citations, refusal when nothing relevant is found, and evaluation, cost and latency.

    Mid-Level Coding .NET and AI Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  17. How does function (tool) calling work with an LLM in .NET? Show how you describe C# methods as tools with Microsoft.Extensions.AI, let the model call them, validate the arguments, and stop it doing something it shouldn't.

    Function and tool calling in .NET: the model returns tool-call requests with JSON arguments, the app executes them; AIFunctionFactory, ChatOptions.Tools and UseFunctionInvocation; schemas from method signatures and descriptions; argument validation, authorisation in the tool, iteration limits, approval for side effects, and structured output.

    Mid-Level Coding .NET and AI Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  18. In 2026, when would you use Microsoft.Extensions.AI, Semantic Kernel or the Microsoft Agent Framework in a .NET app? Explain what each one is for, how they relate, and how you'd choose for a new project or an existing Semantic Kernel codebase.

    The .NET AI stack in 2026: Microsoft.Extensions.AI as the abstraction layer (IChatClient, IEmbeddingGenerator, middleware), Microsoft.Extensions.VectorData for vector stores, Semantic Kernel's plugins and current maintenance status, and the Microsoft Agent Framework (GA as 1.0 in April 2026) for agents and workflows, with guidance for new and existing projects.

    Mid-Level Theory .NET and AI Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  19. What is prompt injection, and how do you defend a .NET AI feature against it? Explain direct and indirect injection through retrieved documents, emails or tool results, and the layered controls you'd put in place given that no prompt fully prevents it.

    Prompt injection in .NET AI features: direct (user) and indirect (documents, web pages, emails, tool output) injection, why it cannot be fully prevented, and layered defences: least-privilege tools, authorisation in code, delimiting untrusted content, Azure AI Content Safety Prompt Shields, output handling, human confirmation, and red-team evaluation.

    Senior Security .NET and AI Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  20. How do you stop an AI feature leaking data? Talk me through personal information in prompts, tenant and permission isolation in RAG, logging prompts and responses safely, where the model provider processes and keeps data, and what the Privacy Act requires.

    Preventing data leakage in .NET AI features: data minimisation and redaction before prompts, tenant and ACL isolation in vector indexes, safe prompt and response logging with Microsoft.Extensions.Compliance.Redaction, provider data handling (Azure OpenAI residency, abuse-monitoring retention), output filtering, and Privacy Act 1988 obligations (APP 6, 8, 11, NDB, automated-decision transparency).

    Senior Security .NET and AI Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me