Senior .NET Developer
60+ Senior .NET Developer Interview Questions and Answers
Q1. Find indexes of two values in an array who's Sum is 8 or a dynamic value
Find indexes of two values in an array whose sum is 8 or a dynamic value
Iterate through the array and store the indexes of each element in a dictionary with the difference between the target sum and the element as the key
Check if the current element exists in the dictionary, if so, return the indexes of the two elements
Handle cases where the target sum is dynamic by replacing 8 with a variable
Q2. what are Microservices? How to manage load balancing in Microservices?
Microservices are a software architecture design where applications are broken down into smaller, independent services that communicate with each other through APIs.
Microservices are designed to be small, focused, and independently deployable services.
Each microservice typically performs a single function or task within the application.
Microservices communicate with each other through APIs, often using lightweight protocols like HTTP or messaging queues.
Load balancing in micr...read more
Senior .NET Developer Interview Questions and Answers for Freshers
Q3. what is extension method ,value type and reference type ,migration in codefirst approach,Configure menthod in dotnet core ,
Extension methods allow adding new methods to existing types, value types store data directly, reference types store references to data, migration in code-first approach involves updating database schema, Configure method in .NET Core configures services and middleware.
Extension methods are static methods that can be called as if they were instance methods on an existing type.
Value types store data directly on the stack, while reference types store references to data on the h...read more
Q4. What are the differences between .Net and .Net Core?
The main difference is that .NET Core is open-source and cross-platform while .NET Framework is Windows-only.
Both are used for building Windows applications, but .NET Core can also be used for web and cloud applications.
.NET Core has a smaller runtime and can be deployed as a single executable file.
.NET Core supports Docker containers and can be used on Linux and macOS.
.NET Framework has a larger runtime and requires installation on the target machine.
Some libraries and APIs ...read more
Q5. what are Design Patters? What is DI?
Design patterns are reusable solutions to common problems in software design. DI stands for Dependency Injection, a design pattern used to inject dependencies into a class.
Design patterns are best practices for solving common software design problems.
DI is a design pattern where dependencies are injected into a class rather than created within the class.
Examples of design patterns include Singleton, Factory, and Observer.
Dependency Injection helps improve code maintainability...read more
Q6. How to use DI in .Net Core
DI in .Net Core allows for loosely coupled and testable code.
Add services to the DI container in Startup.cs
Inject dependencies into classes using constructor injection
Use built-in DI or third-party libraries like Autofac
Configure lifetime of services with AddScoped, AddTransient, or AddSingleton
Share interview questions and help millions of jobseekers 🌟
Q7. What are different ways to Inject services
Different ways to inject services in .NET
Constructor Injection: Services are injected through a class constructor
Property Injection: Services are injected through public properties
Method Injection: Services are injected as method parameters
Service Locator Pattern: Services are accessed through a central registry
DI Containers: Frameworks like Autofac, Unity, or Ninject manage service injection
Q8. What is the return type for controller actions
The return type for controller actions in .NET is typically ActionResult.
The return type for controller actions can be ActionResult, ViewResult, PartialViewResult, JsonResult, ContentResult, RedirectResult, RedirectToRouteResult, FileResult, HttpNotFoundResult, HttpStatusCodeResult, etc.
ActionResult is a base class for all action results in ASP.NET MVC.
Example: public ActionResult Index() { return View(); }
Senior .NET Developer Jobs
Q9. what are difference between put , patch and post
PUT is used to update or replace an existing resource, PATCH is used to partially update a resource, and POST is used to create a new resource.
PUT is idempotent, meaning multiple identical requests will have the same effect as a single request.
PATCH is not necessarily idempotent and is used to make partial updates to a resource.
POST is used to create a new resource on the server.
Q10. Difference between function and stored procedure in SQL
Functions return a single value while stored procedures can perform multiple operations and return multiple values.
Functions return a single value while stored procedures can return multiple values.
Functions are used for computations and return values, while stored procedures are used for executing a sequence of statements.
Functions can be called from within SQL statements, while stored procedures are called using the EXECUTE statement.
Functions cannot modify the database sta...read more
Q11. Write a code for pop node from stack data structure.
Code to pop a node from a stack data structure in C#.
Create a method to remove and return the top element from the stack.
Check if the stack is empty before popping the node to avoid errors.
Decrement the top index after popping the node to update the stack.
Q12. How JWT authentications work in Web API
JWT authentication in Web API involves generating a token with user credentials and validating it on subsequent requests.
JWT stands for JSON Web Token, which is a compact and self-contained way for securely transmitting information between parties as a JSON object.
In Web API, a JWT token is generated upon successful authentication and is sent to the client.
The client includes the JWT token in the Authorization header of subsequent requests to access protected resources.
The We...read more
Q13. Difference between stored procedure and Stored functions
Stored procedures are used to perform a set of actions, while stored functions return a single value.
Stored procedures can perform multiple actions and can return multiple result sets.
Stored functions are used to return a single value and cannot perform DML operations.
Stored functions can be used in SELECT statements, while stored procedures cannot be used in SELECT statements.
Q14. DB schema creation for cinducting an online test
DB schema for online test
Create tables for questions, answers, users, and results
Use foreign keys to link tables together
Include fields for question type, difficulty level, and time limit
Store user responses and calculate scores
Consider security measures to prevent cheating
Q15. Ho to add validation in MVC
Validation in MVC
Use data annotations for server-side validation
Use jQuery validation for client-side validation
Customize validation messages using ErrorMessage property
Use ModelState.IsValid to check if validation passed
Use ModelState.AddModelError to add validation errors
Q16. Ho to Use Transactions in Sql
Transactions in SQL ensure data consistency and integrity during multiple operations.
Transactions group multiple SQL statements into a single unit of work.
They ensure that all statements are executed or none are executed.
They provide data consistency and integrity during multiple operations.
Transactions can be started with BEGIN TRANSACTION and committed with COMMIT or rolled back with ROLLBACK.
They are useful in situations where multiple operations need to be performed atomi...read more
Q17. What are Middleware and filters
Middleware and filters are components in ASP.NET Core that allow you to handle requests and responses in the pipeline.
Middleware are components that are added to the request pipeline to handle requests and responses.
Filters are used to implement cross-cutting concerns like logging, exception handling, and authorization.
Middleware can be used to modify the request or response before it reaches the controller action.
Filters can be applied globally, at the controller level, or a...read more
Q18. Difference between Entity Framework and ADO.Net
Entity Framework is an ORM that simplifies data access in .NET applications, while ADO.Net is a low-level data access technology.
Entity Framework is an Object-Relational Mapping (ORM) framework that allows developers to work with databases using .NET objects.
ADO.Net is a set of classes that allows developers to interact with data sources like databases directly using SQL commands.
Entity Framework provides higher level of abstraction and reduces the amount of code needed for d...read more
Q19. How to store two values in same html tag
You can store two values in the same HTML tag by using data attributes or hidden inputs.
Use data attributes to store additional data in HTML tags, such as
Use hidden inputs to store values that are not displayed on the page, such as
Q20. Ho to call DI in controller
To call DI in controller, inject the required service in the constructor of the controller.
Add required service in ConfigureServices method of Startup.cs
Inject the service in the constructor of the controller
Use the service in the controller methods
Q21. What are the Design patterns?
Design patterns are reusable solutions to common software development problems.
Design patterns provide proven solutions to recurring problems in software development.
They help in creating code that is more flexible, reusable, and maintainable.
Some common design patterns include Singleton, Factory, Observer, and Decorator.
Design patterns can be categorized into three types: Creational, Structural, and Behavioral.
Q22. What is Dependency Injection?
Dependency Injection is a design pattern that allows objects to receive dependencies rather than creating them internally.
DI is a way to achieve loose coupling between objects
It helps in creating more testable and maintainable code
DI can be implemented using constructor injection, property injection, or method injection
Example: Instead of creating a database connection object inside a class, we can inject it from outside
Example: ASP.NET Core uses DI to inject services into co...read more
Q23. What is the Expected CTC?
Expected CTC depends on various factors such as experience, skills, location, and company policies.
Expected CTC can vary based on the candidate's experience and skills.
Location can also play a role in determining the Expected CTC.
Company policies and budget can also impact the Expected CTC.
It is important to research industry standards and negotiate based on market rates.
Providing a specific number may limit negotiation opportunities.
Q24. Difference between single & first in linq
Single returns the only element of a sequence, or a default value if the sequence is empty. First returns the first element of a sequence, or a default value if the sequence contains no elements.
Single throws an exception if the sequence contains more than one element, while First does not.
Single is useful when you expect only one element in the sequence, while First is used when you just need the first element.
Example: var singleElement = list.Single(); var firstElement = li...read more
Q25. How to Use Webapi
WebAPI is a framework for building HTTP services that can be consumed by a broad range of clients.
Create a new WebAPI project in Visual Studio
Define API endpoints using HTTP verbs (GET, POST, PUT, DELETE)
Use attribute routing to map URLs to actions
Return data in JSON format
Secure the API using authentication and authorization
Q26. Write a query to join two tables using LINQ
Join two tables using LINQ
Use the join keyword to combine two tables based on a common field
Specify the fields to be joined using the equals keyword
Select the desired fields from both tables using the select keyword
Q27. Clustered vs Non-Clustered
Clustered indexes determine physical order of data, non-clustered indexes are separate structures.
Clustered indexes sort and store data rows in the table based on their key values.
Non-clustered indexes have a separate structure that includes the indexed columns and a pointer to the data row.
Tables can have only one clustered index, but multiple non-clustered indexes.
Clustered indexes are faster for retrieving large amounts of data, while non-clustered indexes are faster for r...read more
Q28. Query Optimization in Sql
Query optimization in SQL
Use indexes to speed up queries
Avoid using SELECT *
Use JOINs instead of subqueries
Avoid using functions in WHERE clauses
Use EXPLAIN to analyze query performance
Q29. write code for event and Delegate
Event and Delegate code example in C#
Create a delegate with the signature of the method you want to subscribe to
Define an event using the delegate type
Subscribe to the event by adding methods to the event delegate
Raise the event to notify subscribers
Q30. How to handle error in SQL
Errors in SQL can be handled using try-catch blocks, error handling functions, and logging mechanisms.
Use try-catch blocks to catch and handle errors in SQL queries
Utilize error handling functions like @@ERROR, ERROR_MESSAGE(), and ERROR_NUMBER() to retrieve error information
Implement logging mechanisms to track and monitor errors for troubleshooting
Consider using transactions to ensure data integrity and rollback changes in case of errors
Q31. What is the OOP concepts?
OOP concepts are the fundamental principles of Object-Oriented Programming.
Encapsulation - bundling of data and methods that operate on that data
Inheritance - ability of a class to inherit properties and methods from a parent class
Polymorphism - ability of objects to take on multiple forms or have multiple behaviors
Abstraction - hiding of complex implementation details and showing only essential features
Examples: class, object, inheritance, encapsulation, polymorphism, abstra...read more
Q32. Difference between ref & out keyword
ref is used for passing a variable by reference, out is used for returning a value from a method
ref keyword is used to pass a variable by reference, allowing the method to modify the variable
out keyword is used to return a value from a method, the variable passed must be assigned a value within the method
ref parameters must be initialized before passing to the method, out parameters do not need to be initialized
Q33. What is Private Constructor
A private constructor is a constructor that can only be accessed within the class in which it is defined.
Private constructors are used to prevent the instantiation of a class from outside the class itself.
They are commonly used in classes that contain only static members and do not need to be instantiated.
Private constructors are also used in singleton design pattern to ensure that only one instance of a class can be created.
Q34. What is encapsulation
Encapsulation is the process of hiding internal implementation details and exposing only necessary information to the outside world.
Encapsulation helps in achieving data abstraction and data hiding.
It allows for better control over the data by preventing direct access to it.
Encapsulation promotes code reusability and maintainability.
Example: In a class, private variables can be encapsulated and accessed through public methods.
Q35. What is model-view-model
Model-View-ViewModel (MVVM) is a software architectural pattern that separates the development of the graphical user interface (the view) from the business logic (the model) using a mediator called the view model.
MVVM is commonly used in the development of desktop and mobile applications.
The model represents the data and business logic of the application.
The view is responsible for displaying the user interface.
The view model acts as a bridge between the view and the model, p...read more
Q36. What is MVC Architecture
MVC Architecture is a software design pattern that separates an application into three main components: Model, View, and Controller.
Model represents the data and business logic of the application.
View is responsible for displaying the user interface.
Controller handles user input, updates the model, and interacts with the view.
MVC promotes separation of concerns, making the application easier to maintain and test.
Example: In a web application, the model could be a database, th...read more
Q37. Advantage of dotnet core over dotnet
Dotnet core is faster, cross-platform, open-source and modular compared to dotnet.
Dotnet core is faster and more efficient than dotnet.
Dotnet core is cross-platform, meaning it can run on Windows, Linux, and macOS.
Dotnet core is open-source, allowing developers to contribute to its development and customize it to their needs.
Dotnet core is modular, allowing developers to use only the components they need, reducing the size of the application.
Examples of companies using dotnet...read more
Q38. Explain Angular hooks or lifecycle
Angular hooks or lifecycle are methods that allow developers to tap into key moments in a component's lifecycle.
Angular components have several lifecycle hooks such as ngOnInit, ngOnChanges, ngDoCheck, ngOnDestroy, etc.
These hooks allow developers to perform actions at specific points in a component's lifecycle, such as initialization, change detection, and destruction.
For example, ngOnInit is used to initialize data in a component when it is first created, while ngOnDestroy ...read more
Q39. Dependency injection in .net core
Dependency injection in .NET Core allows for loosely coupled components and easier testing.
Dependency injection is a design pattern where components are given their dependencies rather than creating them internally.
In .NET Core, dependency injection is built-in and can be configured in the ConfigureServices method of the Startup class.
Services are registered in the ConfigureServices method and can be injected into controllers, services, or other components.
Example: services.A...read more
Q40. On which port .Net runs
The .NET framework does not run on a specific port. It runs on top of the operating system and uses the underlying network protocols.
The .NET framework does not have its own port number.
It relies on the operating system's network stack to handle network communication.
Applications built with .NET can listen on any available port specified by the developer.
For example, a web application built with ASP.NET can listen on port 80 for HTTP traffic.
Q41. What is WCF throttling
WCF throttling is a mechanism to control the number of concurrent requests and resources used by a WCF service.
WCF throttling helps prevent resource exhaustion and performance degradation.
Throttling settings can be configured in the WCF service configuration file.
Throttling parameters include maximum concurrent calls, sessions, and instances.
Examples of throttling settings are maxConcurrentCalls, maxConcurrentSessions, and maxConcurrentInstances.
Q42. Inner vs Outer Join
Inner join returns only matching records while outer join returns all records from both tables.
Inner join is used to retrieve records that have matching values in both tables.
Outer join is used to retrieve all records from both tables, even if there are no matching values.
Left outer join returns all records from the left table and matching records from the right table.
Right outer join returns all records from the right table and matching records from the left table.
Q43. drop ,delete and truncate difference
Drop, delete, and truncate are SQL commands used to remove data from a table, but they have different functionalities.
DROP: Used to remove an entire table or database
DELETE: Used to remove specific rows from a table
TRUNCATE: Used to remove all rows from a table, but keeps the table structure
Q44. What is middleware
Middleware is software that acts as a bridge between different applications or systems, allowing them to communicate and share data.
Middleware helps in integrating different software components and systems.
It provides a layer of abstraction for communication between applications.
Examples of middleware include message brokers like RabbitMQ, web servers like Apache, and API gateways like Kong.
Q45. Opps concepts in c#.Net
Object-oriented programming concepts in C#
Encapsulation: bundling of data and methods that manipulate the data
Inheritance: creating new classes from existing ones
Polymorphism: ability of objects to take on multiple forms
Abstraction: hiding implementation details and showing only necessary information
Q46. What is constructor
A constructor is a special method in a class that is used to initialize objects of that class.
Constructors have the same name as the class they belong to.
They are called automatically when an object is created.
Constructors can have parameters to initialize the object with specific values.
They can be overloaded to provide multiple ways of object initialization.
Q47. What is razor pages
Razor Pages is a feature of ASP.NET Core that allows developers to build web pages using a simplified programming model.
Razor Pages provide a way to create web pages with minimal code-behind files.
They use the Razor syntax for rendering HTML and executing server-side code.
Razor Pages follow the MVVM (Model-View-ViewModel) pattern.
They are an alternative to the traditional MVC (Model-View-Controller) pattern.
Razor Pages are well-suited for small to medium-sized applications wi...read more
Q48. What is generics
Generics are a way to create reusable code that can work with different data types.
Generics allow for type safety and reduce code duplication.
They are used in collections such as List
and Dictionary . Generics can also be used in methods and classes.
Example: List
names = new List (); Example: Dictionary
employees = new Dictionary ();
Q49. What is primary key
Primary key is a unique identifier for a record in a database table.
Primary key ensures data integrity and helps in faster data retrieval.
It cannot have null values and must be unique for each record.
Examples of primary keys are social security number, email address, etc.
Q50. Write custom middleware
Custom middleware in .NET allows for custom logic to be executed before or after an HTTP request is processed.
Create a class that implements the IMiddleware interface
Override the InvokeAsync method to add custom logic
Register the middleware in the Startup class using the UseMiddleware extension method
Interview Questions of Similar Designations
Top Interview Questions for Senior .NET Developer Related Skills
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month