DotNet Interview Questions
DotNet Interview Questions
.NET Framework is a platform created by Microsoft to build and run software applications. It includes a large library
of pre-built code (Framework Class Library) that developers can use, and it supports multiple programming languages
like C#, VB.NET, and F#. It provides tools and libraries to develop applications for various platforms, including Windows,
web, mobile, and more.
- **Value Types:** These hold the actual value within their memory space. Examples are integers, floating-point
numbers, and structs. They are stored directly where they are declared, making access faster.
- **Reference Types:** These store references or pointers to where the data is held in memory. Examples include
objects, arrays, and classes. They are stored in the heap memory and need to be accessed indirectly via these
references, making them a bit slower than value types.
Namespaces are used to organize and group related classes, interfaces, structures, enumerations, and delegates in
.NET. They prevent naming conflicts and make it easier to manage and locate classes within larger applications.
CLR is the core part of the .NET Framework responsible for managing the execution of .NET programs. It handles tasks
like memory management, code compilation, code execution, and exception handling. It ensures that .NET programs
run efficiently and securely by providing features like garbage collection and type safety.
- **Managed Code:** Code that runs under the control of CLR is called managed code. It's written in .NET languages
and benefits from CLR's services like automatic memory management (garbage collection) and type safety.
- **Unmanaged Code:** Code that doesn't run under CLR's control. It's typically written in languages like C or C++ and
requires manual memory management and lacks the services provided by CLR.
**Intermediate Level:**
C# (pronounced as C-sharp) is a programming language developed by Microsoft specifically for building .NET
applications. It's closely tied to the .NET Framework and provides a powerful and easy-to-learn syntax for developers.
- **Private Assemblies:** These contain resources that are used by a single application. They're kept within the
application's directory.
- **Shared Assemblies:** These contain resources that can be shared by multiple applications. They are stored in the
Global Assembly Cache (GAC) to facilitate their sharing across applications.
Garbage collection is the process by which the CLR automatically manages memory by identifying and freeing up
memory that is no longer in use (i.e., not referenced by any part of the program). It prevents memory leaks and helps
in efficient memory utilization.
The GAC is a central repository that stores shared assemblies intended to be used by multiple applications. It helps
in versioning and sharing of assemblies across different applications, ensuring that multiple applications can use the
same assembly without conflicts.
The JIT (Just-In-Time) compiler in .NET converts the Intermediate Language (IL) code, generated by the language
compiler, into native machine code that the processor can execute. It does this on demand at runtime, improving
performance by compiling only the necessary code.
**Advanced Level:**
Delegates are similar to function pointers in C++. They are type-safe, object-oriented, and can reference one or more
methods. Events in C# are built on delegates and allow objects to notify other objects when something significant
happens.
12. **Explain the concept of inheritance and how it's implemented in C#.**
Inheritance is a fundamental concept in object-oriented programming where one class (derived or child class)
inherits properties and behaviors from another class (base or parent class). In C#, inheritance is implemented using
the colon (:) symbol to indicate the derived class and the base class.
Access modifiers control the visibility or accessibility of classes, methods, variables, etc.
Collections in .NET are data structures used to store and manipulate groups of objects. They include Lists, Arrays,
Dictionaries, Queues, and Sets. Each collection type has its unique way of organizing and managing data, catering to
specific needs like ordering, searching, and uniqueness of elements.
LINQ is a powerful feature in .NET that enables developers to write queries directly within C# or VB.NET code to
retrieve and manipulate data from different sources such as databases, XML, and collections. It allows for a more
natural and readable way of querying data, similar to SQL.
16. **What is ASP.NET and how does it differ from ASP.NET Core?**
ASP.NET is a web application framework developed by Microsoft for building web applications using .NET Framework.
ASP.NET Core, on the other hand, is a cross-platform and open-source framework for developing modern web
applications. It's more modular, lightweight, and can run on multiple platforms.
MVC is a design pattern used in ASP.NET for organizing code into three interconnected components:
- **Controller:** Handles user input, processes requests, and interacts with the model to control the application
flow.
Middleware in ASP.NET Core is a series of components that are combined to form the request pipeline. Each
middleware component can handle an aspect of an HTTP request or response, such as authentication, logging, routing,
etc.
19. **What is Entity Framework in .NET? How does it simplify database interactions?**
Entity Framework is an Object-Relational Mapping (ORM) framework in .NET that enables developers to work with
databases using .NET objects. It eliminates the need for writing complex SQL queries by allowing developers to interact
with databases using familiar object-oriented programming techniques.
20. **Discuss the differences between .NET Core and .NET Framework.**
- **.NET Core:** It's a modern, cross-platform framework that's open-source and modular. It's designed for building
applications that can run on Windows