Top .NET Interview Questions & Answers – Advanced Edition

blog7

Top .NET Interview Questions & Answers – Advanced Edition

  • If you’re preparing for senior or mid-level .NET interviews, expect questions beyond syntax. Here are some advanced Q&A you should be ready for:

Questions & Answers

  • Que1: What is the difference between IEnumerable, IQueryable, and List in .NET?
  • Ans: IEnumerable works in-memory and is best for simple iteration.
  • Ans: IQueryable allows deferred execution and runs queries on the database side.
  • Ans: List is a concrete in-memory collection with indexing and modification support.
  • Que2: Explain the difference between Task, Thread, and ValueTask.
  • Ans: Thread: OS-level execution unit.
  • Ans: Task: Higher-level abstraction over threads for async operations.
  • Ans: ValueTask: Optimized for scenarios where the result may already be available, reducing allocations.
  • Que3: How does Dependency Injection (DI) work in .NET Core?
  • Ans: .NET Core has a built-in IoC container. Services are registered with lifetimes:
  • Ans: Singleton (one instance per application), Scoped (one instance per request)
  • Ans: Transient (new instance every time)
  • Ans: This promotes loose coupling and testability.
  • Que4: What’s the difference between struct and class in C#?
  • Ans: struct is a value type, stored on the stack, lightweight, and doesn’t support inheritance.
  • Ans: class is a reference type, stored on the heap, supports inheritance, and is more flexible.
  • Que5: How do you improve performance in an ASP.NET Core application?
  • Ans: Use caching (in-memory, distributed, response caching)
  • Ans: Use async/await properly
  • Ans: Optimize EF Core queries (projection, AsNoTracking())
  • Ans: Profile & monitor with Application Insights