.NET Core Interview Questions

🧠 C# & .NET Interview Q&A (Core Concepts)

A quick and structured guide covering commonly asked .NET, C#, LINQ, and SQL interview questions.


1️⃣ Difference Between ref and out

  • ref → Variable must be initialized before passing.

  • out → Variable does not need initialization before passing.


2️⃣ Difference Between Abstract Class and Interface

🔹 Abstract Class

  • abstract keyword is used.

  • Cannot be instantiated.

  • Can have both abstract and non-abstract methods.

🔹 Interface

  • interface keyword is used.

  • Contains only abstract methods.

  • Supports multiple inheritance.

🔹 Abstract Method

  • Method without implementation (only signature).


3️⃣ Types of Access Modifiers

  • public → Accessible from anywhere.

  • private → Accessible only within the class.

  • protected → Accessible in derived classes.

  • internal → Accessible within the same assembly.

  • private protected → Accessible within same class or derived class in same assembly.


4️⃣ What is Singleton Pattern?

  • Ensures that only one instance of a class is created.

  • Commonly used for logging, caching, configuration.


5️⃣ What is using Keyword?

  • Used to import namespaces/libraries.

  • Also used to define a scope for automatic memory/resource disposal.


6️⃣ Concept of Dependency Injection (DI)

  • A design pattern based on IoC (Inversion of Control).

  • Dependencies are injected from external sources instead of creating inside class.

🔹 Lifetimes in .NET Core:

  • AddTransient → New instance every time.

  • AddScoped → One instance per request.

  • AddSingleton → Single instance throughout application lifecycle.


7️⃣ What is LINQ?

  • Language Integrated Query

  • Used to query:

    • Databases (via Entity Framework)

    • In-memory collections

  • Provides built-in methods for filtering, sorting, grouping.


8️⃣ Difference Between String and StringBuilder

  • String → Immutable (cannot change after creation)

  • StringBuilder → Mutable (can modify without creating new object)


9️⃣ Difference Between async and await

  • async → Marks a method as asynchronous.

  • await → Waits for task completion without blocking thread.


🔟 IEnumerable vs IQueryable

  • IEnumerable → Works with in-memory collections (List, Array).

  • IQueryable → Works with external data sources (Database, EF).


1️⃣1️⃣ Exception Handling in ASP.NET Core

  • Global Exception HandlingUseExceptionHandler()

  • try-catch → Local handling

  • ILogger → Logging errors and messages


1️⃣2️⃣ What is Entity Framework?

  • ORM (Object Relational Mapper)

  • Allows interaction with DB using C# objects instead of SQL


1️⃣3️⃣ JOIN vs INNER JOIN in SQL

  • No difference → Both are interchangeable.


1️⃣4️⃣ Caching in ASP.NET

  • IMemoryCache → In-memory caching

  • IDistributedCache → External caching (e.g., Redis)


1️⃣5️⃣ Security in .NET Web API

  • JWT (JSON Web Token) → Authentication

  • OAuth → Third-party authentication

  • Role-Based Authorization

  • Claims-Based Authorization


🧠 Key Takeaways

  • Focus on core fundamentals + practical usage.

  • Understand real-world application of concepts like DI, caching, security.

  • These topics are highly relevant for .NET interviews (L1–L3 levels).


This acts as a quick revision sheet for interviews and daily development reference.

Comments