A namespace is used to organize related classes and avoid naming conflicts. Think of it like folders on your laptop—two files can have the same name as long as they are in different folders. In real projects, namespaces help keep code clean, readable, and manageable when applications grow large.
Interview Flashcards & Mock Mode
Practice with 3D flip cards, voice reader, and timed interview simulations.
CodeShot.in — Daily Challenges
60-second in-browser coding micro-challenges to sharpen syntax and problem-solving speed.
What is a namespace in .NET and why do we use it?
What is the difference between a class and an interface in .NET?
A class is something you can create an object from and it can contain implemented methods, properties, and fields. An interface is a contract—it only declares what methods a class must implement. Real-world analogy: a class is a car you can drive, while an interface is the rulebook that says every car must have brakes and steering.
What is dependency injection in .NET and why is it useful?
Dependency Injection means giving an object its dependencies from the outside instead of creating them inside the class. Think of it like ordering food from a restaurant instead of cooking everything yourself. It makes code loosely coupled, easier to test, and easier to maintain.
What is LINQ in .NET and why do developers use it?
LINQ allows you to query collections in C# using SQL-like syntax. For example, filtering a list of users without writing loops. It’s like using Google search instead of manually scanning every page of a book—cleaner, readable, and less error-prone.
How do you handle environment configuration in Node.js or .NET?
Environment configuration separates settings for development, testing, and production. For example, using .env files in Node.js or appsettings.json in .NET. It’s like having different modes on your phone—silent at work, loud at home—same phone, different behavior.
What is async/await in .NET and how does it improve application responsiveness?
Async/await allows methods to run without blocking the main thread while waiting for long-running tasks like API calls or database queries. It’s like ordering food at a restaurant—you don’t stand in the kitchen waiting; you sit and relax until the food arrives. In web apps, this keeps the UI responsive and allows the server to handle more requests.
What happens if you use async without await?
If you use async without await, the method runs asynchronously but you don’t wait for its result. This can lead to unexpected behavior, like code continuing before the task is finished. It’s like ordering food and leaving the restaurant without waiting to receive it.
Does async/await improve performance or just responsiveness?
Async/await mainly improves responsiveness and scalability, not raw performance. It allows better use of threads, especially in I/O operations, but CPU-bound tasks won’t run faster just because they are async.
What are extension methods in .NET?
Extension methods allow you to add new methods to existing classes without modifying their source code. It’s like installing an app to add features to your phone instead of changing the hardware.
What are limitations of extension methods?
Extension methods cannot access private members of a class and do not truly modify the class—they are resolved at compile time. Overuse can also make code harder to understand.
What is the Repository Pattern in .NET?
The Repository Pattern abstracts the data access layer, separating business logic from database operations. It's like a librarian—you ask for a book by title and they handle finding it. Your code doesn't care if data comes from MySQL, MongoDB, or a file.
What is the difference between Repository Pattern and Unit of Work?
Repository handles data operations for a single entity. Unit of Work coordinates multiple repositories in a single transaction, ensuring all changes are committed or rolled back together.