C#_2

 

C# Interview Questions for 3+ Years Experience

This markdown file contains common interview questions and key topics for C# developers with 3+ years of experience. It's organized by categories for easy reference.

Object-Oriented Programming (OOP)

  • Explain the four pillars of OOP: Encapsulation, Inheritance, Polymorphism, and Abstraction.
  • What is the difference between an abstract class and an interface? When would you use each?
  • Describe method overloading vs method overriding.
  • What is the difference between a struct and a class in C#? When should you use a struct?
  • Explain the concept of boxing and unboxing in C#.

LINQ (Language Integrated Query)

  • What is LINQ and why is it useful?
  • Explain the difference between IEnumerable and IQueryable.
  • What is deferred execution in LINQ? Provide an example.
  • How does LINQ work with different data sources (e.g., SQL, XML, in-memory collections)?
  • What are the main LINQ operators (Select, Where, OrderBy, GroupBy, Join)?

Asynchronous Programming

  • Explain the async/await keywords in C#.
  • What is the difference between Task and Task?
  • How does the Task Parallel Library (TPL) work?
  • What are common pitfalls when using async/await?
  • Explain the concept of async void vs async Task.

Entity Framework (EF)

  • What is Entity Framework? Explain Code First vs Database First approaches.
  • What is lazy loading vs eager loading in EF?
  • How do you handle the N+1 query problem in EF?
  • Explain migrations in EF Core.
  • What are the different types of relationships in EF (One-to-One, One-to-Many, Many-to-Many)?

ASP.NET Core

  • Explain the MVC pattern in ASP.NET Core.
  • What is the difference between MVC and Web API in ASP.NET Core?
  • How does dependency injection work in ASP.NET Core?
  • What is middleware in ASP.NET Core? Provide examples.
  • Explain the request pipeline in ASP.NET Core.

Design Patterns and Principles

  • Explain the SOLID principles.
  • Describe common design patterns: Singleton, Factory, Repository, Observer.
  • What is dependency injection and why is it important?
  • Explain the Repository pattern and Unit of Work pattern.
  • How do you implement the Strategy pattern in C#?

Unit Testing and TDD

  • What are the benefits of unit testing?
  • Explain mocking and why it's important in unit testing.
  • What testing frameworks are available for C# (NUnit, xUnit, MSTest)?
  • What is Test-Driven Development (TDD)?
  • How do you test asynchronous code?

Performance and Optimization

  • Explain garbage collection in C#.
  • What are value types and reference types? How do they affect performance?
  • How do you optimize LINQ queries for performance?
  • What tools can you use for profiling C# applications?
  • Explain memory leaks in C# and how to avoid them.

Security

  • What are common security vulnerabilities in C# applications?
  • Explain SQL injection and how to prevent it.
  • What is Cross-Site Scripting (XSS) and how to mitigate it?
  • How does authentication and authorization work in ASP.NET Core?
  • What is HTTPS and why is it important?

Miscellaneous

  • What are generics in C#? Why are they useful?
  • Explain delegates, events, and lambda expressions.
  • What is reflection in C# and when would you use it?
  • How does exception handling work in C#?
  • What are the differences between .NET Framework, .NET Core, and .NET 5+?

Coding Challenges

  • Implement a thread-safe singleton.
  • Write a LINQ query to group and aggregate data.
  • Create an async method that processes a list of items concurrently.
  • Design a simple REST API endpoint using ASP.NET Core.

This list is not exhaustive but covers key areas for mid-level C# developers. Practice explaining concepts with code examples and real-world scenarios.

Comments

Popular posts from this blog