75 Essential .NET Interview Questions And Answers You Must Ask

75 Essential .NET Interview Questions And Answers You Must Ask

According to CodinGame, .NET currently holds the most popular amongst developers followed by Node.js and then React. The survey polled around 15,000 developers and HR professionals from more than 60 countries in late 2020.

.NET has gained popularity among developers for its ease of use, scalability, and readily available libraries. As a result, more programmers are transitioning to .NET for their programming needs which have put increased pressure on employers needing qualified .NET developers.

As it is challenging to find the right .NET developer for your company, you should validate whether or not they have experience with this technology. This will give you an indication of their knowledge level.

To help you assess your candidates, we have compiled a list of the top 75 .NET interview questions and answers. These questions and answers should give you an idea if the .NET developer is knowledgeable or not. If they are, then you know what to do.

Best .NET Interview Questions and Answers

General .NET interview questions and answers

1 What is the .NET Framework?

The .NET framework is a software framework developed by Microsoft that primarily reaches Windows, which can be used for building, deploying, and running applications that use the .NET technologies such as desktop and web applications. ASP.Net 4.0 beta is the successor to ASPs (Active Server Pages). It’s a server-side runtime environment in order to create dynamic content like MVC, HTML, Javascript, CSS etc.; it supports multiple page extensions required for the development of websites including aspx., asmx., ascx., ashx.

2 Are .NET applications platform independent?

.NET is not platform dependent. .NET framework is a software framework developed by Microsoft that primarily runs on windows, which can be used for building, deploying, and running applications that use .NET technologies such as desktop and web applications. .Net application can also run on MAC OSX where .NET runtime is also available (this would require you to compile the source code using xCode).Other platforms like Raspberry PI are also supporting .Net development.

3 What is ASP.Net?

ASP .Net is a successor of Active Server Pages. It is an open-source server-side web application framework that can be used for developing dynamic websites and web applications.

The .NET Framework is a Microsoft-developed framework that primarily runs on Windows. This framework can be used for building, deploying, and running applications that use .NET technologies such as desktop and web applications. ASP.NET 4.0 (the latest version) is the successor of Microsoft’s Active Server Pages platform; it provides various extensions, including page extensions like aspx, asmx, ascx, ashx, etc., which are being used to develop Web sites with

ASP.NET 4 or earlier versions have been released from November 2006 to July 2010.

4 What is MVC?

The Model-View-Controller framework is used to create web applications, which rely on a model that separates the application logic from the User Interface. Input and Events are controlled by the Controller. The Model contains the business logic of the application and is not dependent on any web technology. It uses a data access layer to talk to a database, and itself talks to the user through The View.

The MVC architecture is used in .NET Framework as well as .NET framework applications (like Nintex Workflow Management).

5 How many languages are supported by .NET at present time?

When the .NET framework was first introduced, it supported many languages (VB.NET, C#, Perl, COBOL). At present time, it supports over 44 languages.

6 How is it possible for .NET to support many languages?

The .NET language is compiled to MSIL and this “managed code” can be run in the .NET environment. After compilation, it becomes a barrier-free language that can call or use functions of another programing language.

7 Explain the difference between ASP.NET and ASP.

ASP.NET is a software framework developed by Microsoft that can be used for creating personal or enterprise Windows-based web applications and ASP (Active Server Pages) is a Microsoft server-side technology used to create web pages.

  • ASP.NET is compiled while ASP is interpreted.
  • ASP uses the technology named ADO while ASP.NET uses ADO.NET.
  • ASP.NET is completely object-oriented while ASP is partially object-oriented.

8 What is the difference between trace and debug?

When it comes to building, Debug and Trace both have their uses. Debug is for debugging builds while Trace is typically used only when you want to use debugging with release builds.

9 Explain the differences between system.stringbuilder and system.string

  • system.stringbuilder is a mutable while system.string is immutable.
  • Append keyword is used in system.stringbuilder but not in system.string.

10 Explain the differences between namespace and assembly?

Namespace is .NET grouping concept while Assembly is .NET linking/bundling concept.

11 What are the different types of .net assemblies?

There are four types of .Net assemblies- A console application, Windows application, class library, and dynamic link libraries (DLLs).

12 Explain the differences between value type and reference type.

Value types contain variable data while reference types will contain a reference to the location of that data in memory.

  • In reference type, memory is allocated in managed heap and in value type memory is allocated in stack.
  • Reference type ex-class value type-struct, enumeration

13 Explain the differences between session object and application object.

The session object is used to control the .Net application. The .NET framework automatically creates a session object for every .NET application domain and manages it. The .NET Framework maintains one global collection of all session objects in the HttpContext

14 What are the advantages and disadvantages of using session?

  • Advantages: Sessions are a way to store data in the application so that users can come back to their state without having to start over. They’re more secure and easily implemented when compared with cookies, one of which is impossible.
  • Disadvantages: Performance is impacted if there are a lot of users. Data serialization and deserialization contribute to the performance overhead; this is true for both state server session modes and SQL Server sessions.

15 Explain the boxing and unboxing concept in .Net.

  • Boxing: Boxing is a process of converting value type into a reference type.
  • Unboxing: Unboxing is a process of converting reference type to value type.

16 When will you use boxing in .Net?

Boxing can be used when we assign primitive data types to the object.value types. All basic .NET data types are implemented as classes and thus they are reference types, which means we cannot directly store them in variables that have been declared as containing primitive data structures (for example, int, string, float, etc). In this case, these primitives become boxed and placed into an object.

17 What is HTTPhandler?

The HttpHandler API is a low-level request and response API that’s made to service incoming HTTP requests. Every incoming HTTP request received by ASP.NET eventually gets processed by an instance of a class that implements HttpHandler.

18 What are the memory-mapped files?

Memory-mapped files can be used to map the content of a file into logical addresses for faster access, and so different processes on the same machine can share data. To obtain a memory-mapped file object, you should use the method MemoryMappedFile.CreateFromFiles().

19 What is Garbage collection?

A process that runs in the background and cleans up memory from unreferenced variables is called garbage collection. Garbage collection frees up unused memory when an application has no need for it.

20 Which method is used to enforce garbage collection in .NET?

System.GC.Collect() method is use to enforce garbage collection in .NET .

21 What is the difference between dispose() and finalize()?

While Dispose and Finalize both methods deal with garbage collection of .NET runtime objects, they do their jobs in different ways. Since the finalizer will be called by the runtime automatically, programmers need to call Dispose manually when necessary.

22 Explain the Code Access Security (CAS) in .NET framework.

.NET’s security model is intended to restrict unauthorized access of resources and operations, as well as which code should be used for particular tasks. The Code Access Security system works in a collaboration with the .NET security model to do this.

23  If you want to replace multiple if-else statements in code, which statement will you use?

We can replace multiple If-Else statements in the Visual Basic language with a Select-Case statement. We can replace multiple If-Else statements in C# with a Switch-Case statement.

24 What are cookies?

Cookies are small amounts of data created by servers and sent to browsers, which can be used for various purposes. Cookies allow the server that created them to collect information about a site’s users via the browser.

25 What are the advantages and disadvantages of using cookies?

Advantages of using cookies include:

Advantages: They allow a site to recognize and customize itself for the visitors. They are useful when remembering what users have entered in forms. This is especially true if the user comes back to fill out the form later, or if validation is done on the server-side.

Disadvantages: Some people are opposed to them because of privacy concerns. Also, Cookie can store only string values, not object.

26 What are different types of cookies?

There are several different types of cookies in .NET development. They have been categorized as follow:

Session cookies: These are created by .NET framework for tracking a session or user activity over multiple web pages. They remain in the browser until the time expires (or until the user leaves).

Persistent Cookies: Persistent cookies stay on users’ PC even after they’re closed their browsers. It survives through reboots and upgrades, allowing .NET developers to track users across sessions, or if they don’t close their browser. This kind is also known as ” 2 nd -party” cookie since it’s created by third-party websites . Session id is stored this type of cookie.

Web Storage: Web storage allows information such as name, address and telephone number of the .NET developer to be saved. It refers to browser storage space, which allows user-defined data . Cookies help .NET programmer in accessing information such as session id .

Session Identifiers: The process of identifying users is known as session identifiers . Here, .NET developer keep a cookie that contains an encrypted value. Session identifier can also be created by using URLs. These identifiers are used for tracking and managing sessions .

27 What are the differences between function and stored procedure in .Net programming language?

Two ways to perform calculations are functions and procedures. Functions can return one value but procedures can return more than one depending on the result of a calculation performed with input parameters. Functions cannot be used in select statements, while two or more values may come back from a procedure call.

Functions are designed to accept input and output parameters, whereas procedures can have input or both input and output parameters. Procedures allow exceptions to be handled in try-catch blocks but functions cannot use the same language construct.

28 What is the difference between Hash table and Array list?

Hash tables store data in form of value-name pair whereas array lists are limited to storing only values. In hash arrays, you pass the name of an entry to access its value while for an Array list, you must pass the index number. Hash arrays can hold heterogeneous types of data while an Array list cannot contain anything other than uniform data types.

29 What are the advantages of ASP .NET Web Pages?

ASP .NET WebPages are fast and lightweight. They don’t require any compilation or code signing process on the server-side and they provide great flexibility to create dynamic web pages at run time without writing a single line of code.

30 What languages does the .NET Framework support?

The .NET Framework is a set of programming languages that are designed to be used for building and deploying web and desktop applications. As the current application requires qualified programmers who would be comfortable using these languages, please list any experience in which you have used them.

Though there is some variance in terms of languages supported, the .NET Framework supports more than 60 languages. This includes both Microsoft and non-Microsoft languages. The most common language being VB.NET, Cobol, Perl, C# (C Sharp), C++ (Objective-C) and F# keywords within this framework respectively.

31 What is the difference between a while and for loop?

Developers should know the difference between while and for loops. The for loop is a standard unit of code that executes repeatedly as long as a given statement remains true, whereas the while loop continues to execute until it becomes true.

‘While loop’ is used to repeat a task indefinitely until a certain condition stops it. On the other hand, ‘for loop’ can be used to execute a block of code several times until a particular condition is met or not.

32 Explain what .NET web services are

Web services are elements of an application that enable the interaction between applications and objects over the internet. They allow developers to publish their work publicly in a way other cross platforms can access it for easy, shared use.

With the .NET framework and programming with ASP.NET, programmers can use web services to connect across numerous platforms and languages. The .NET framework includes built-in classes that are made for building and consuming web services.

33 Explain what a delegate is in .NET

The .NET programmer you’re interviewing should be able to explain that using a delegate lets the developer encapsulate a reference to a method inside an object (similarly to pointers in C and C++). Then, this delegate can have code that calls the reference method without needing explicit knowledge about which specific methods will be invoked at compile time.

34 What is the difference between Server.Transfer and Response.Redirect?

A Server.Transfer redirect to another page without a round-trip back to the browser speeds up processing and reduces traffic on the server, but requires more overhead on the client. A Response.Redirect performs a round trip back to the client where it updates their browser history and displays the new address for them.

35 What is ViewState?

ViewState is used to retain the state of the user controls. When a .NET web page is loaded, the .aspx file for that page is compiled into an assembly by the .NET framework and cached on the disk in order to serve as a faster response time for subsequent requests for that .aspx file. The ViewState property of UserControl class allows you to store data in a hidden .Net variable to be “viewed” after each postback event when control values revert back to their original unmodified values. Viewstate can also be used to save validated data across forms in an MVC application.

36 Where the viewstate is stored after the page postback?

ViewState is a hidden form control on the page that persists local data and doesn’t update server.

37 How long the items in ViewState exists?

Items get persisted in ViewState until the control is rendered again, either by a postback to the same URL, or by navigating to a different view.

38 What are the different Session state management options available in ASP.NET?

There’s the In-Process and Out-of-Process (StateServer) options for the Session .

  • The In-Porcess stores the session in memory in the .NET process, so it can only be accessed by .NET code.
  • The Out-of-Process session state management stores data in .MDF database files on a SQL Server, so it can be accessed by .NET code and Web pages.

39 What are delegates?

Delegates define signatures or prototypes for methods without describing their semantics (what they do). Delegation is one way, bidirectional messaging between a “parent” object and its “children.”

40 What is caching and why should .NET developers use it?

Caching is the storing of data or any calculated results so that future requests for that same data can be served faster. .NET developers should cache anything that’s expensive to retrieve or calculate since .NET has many ways to do this and it improves performance—especially on high-load Web servers.

41 What are the different types of caching in ASP.NET?

There are 3 kinds of caching in .NET:

  • .Net Output caching is a .NET developer’s best friend. Output caching stores any .NET page output so that future requests for the same .NET page can be served much faster, and with less processing. It works by storing .NET page output in memory or disk—depending on what you select when setting it up. In most cases, this should be done regardless of .NET framework version since it adds very little overhead—for low to mid traffic .NET pages. It has an expiration date after which the cached data will expire and won’t be served again, unless expired earlier; this depends on your .NET cache provider configuration. When should .Net developers use output caching? Output caching is ideal for .Net developers who want to speed up
  • .Net Fragment caching is used to cache .NET web page fragments that are part of the .Net framework. This can be .NET html controls, .NET server controls and .NET user controls. The .NET cached fragments are stored in either memory or disk – depending on what you select when setting it up. Disk-based .net cached images have an expiration date after which the data will expire and won’t be served again unless it’s expired earlier; this depends on your .net cache provider configuration.
  • .Net Data caching can be defined as .NET .net web page fragment that is stored in the .NET cache. .Net data caching stores .Net dynamic web form variables and .NET user input. The .net cached data including .Net file uploads, .NET cookies and session information are saved by using different.net cache providers such as MemoryCache or OutputCache.

How can you prevent browsers from caching an ASPX page?

You can SetNoStore on HttpCachePolicy object to .NET web page fragment that prevents browsers from .net cache provider configuration.

Advance .NET interview questions and answers

42 Explain the differences between an Interface and an Abstract Class in .NET.

An interface may declare only members with no access modifiers, and all declared members must be implemented by implementing classes.

An abstract class encapsulates functionality and abstract/virtual members that must be implemented by the inheriting entities. It can declare fields too.

Abstract classes and interfaces cannot be instantiated.

43 How do you implement a generic action in WebAPI?

It is not possible as the WebAPI runtime needs to know the method signatures in advance.

44 Discuss the difference between constants and read-only variables.

A constant (const) is a .NET language keyword that can be used to declare variables whose values cannot be changed after they are initialized.

While, .Net read only variable are similar in purpose as constants but .Net support them using the ReadOnly attribute. This means these types of variables can have their values changed but by explicitly stating it .

45 What does Distributed System mean?

It refers to a system with components distributed over network. As .Net is based on Windows OS, its architecture needs to be always aware of remote connections. Thus you need proper servers or middleware to enable .NET applications. This is why distributed systems are dependent on networks. When we have n number of computers that access a particular resource like a Database. This is what we call .NET Distributed System.

46 What are the .Net threads?

.Net Threads refer to any .Net-based application which has more than one thread. As you might know that .Net supports multithreading. When an application has multi-threading, we can increase its performance by assigning a separate thread for executing the various tasks. For example, if you have 10 packets of data and you need to process them in parallel, then it makes sense to handle these packets using multiple threads.

47 What is .NET remoting?

.NET remoting allows you to send .net objects across application domains, process or machine boundaries. . NET Remoting supports the creation of an executable program that can be run on one computer but uses objects created and manipulated by .Net components running on another computer. .NET Remoting is also used for an inter-machine messaging component as well (web services).

48 How many Web Services standards are there?

There are two Web Service standards: SOAP (Simple Object Access Protocol) and REST (Representational State Transfer) . However, Microsoft recognizes more than 80 different types of web service specifications.

49 How do Web Services differ from WCF?

Web Services allow and encourage direct communication between .NET applications. .NET Framework provides support for XML and other data formats, allowing .NET to communicate with any external application or service without requiring additional programming . WCF (Windows Communication Foundation), on the other hand, is an architectural framework that allows .NET components to interact with one another through services. As such, WCF essentially facilitates .NET Remoting.

50 How would you use Web Services in your IT projects?

Let’s assume a company has its main offices in New York, while branches are scattered across the country. In order to keep track of all orders made by customers from each branch, as well as manage inventory and process purchases, one solution may be to create a web service interface for each branch and develop .NET components for.

51 Can we have a web application running without web.Config file?

Yes, you can have a web application without web.config file.

52 Can you create a web application with both webforms and MVC?

Yes. You can create a web application that uses both MVC and WebForms.

53 Can you add code files of different languages in App_Code folder?

No. You can not add code files of different languages.

54 What is Protected Configuration do?

Protected Configuration is .NET Framework feature. Protected Configuration provides a secure mechanism for .NET assemblies to store encrypted configuration settings.

55 What is Cross Page Posting?

When we hit the submit button on a web page, it sends data to the same page. To get the data sent to another web page, you’ll need to use cross-posting. Our previous option, PostBackUrl is good for this.

56 What is RedirectPermanent in ASP.Net?

RedirectPermanent performs a permanent redirect from the requested URL to the specified URL. It also issues 301 Moved Permanently responses.

57 Explain the working of passport authentication.

The application first checks if a passport authentication cookie is stored on the user’s machine. If so, then it retrieves the username and password of that account from the cookie. Otherwise, it redirects to a pass ticket retrieval page. The user must enter their name, password, and date of birth in order to retrieve an authentication token for use with this site.

58 What are the advantages of Passport authentication?

Every website can be reached with a single login. User details are maintained in one location, which means there is no need to keep remembering passwords for every site.

59 What are tuples in .Net?

As an alternative to arrays, tuples are a fixed-length collection of elements. The size of a tuple must be declared upon it its declaration just as with arrays.

60 How many elements a tuple can hold?

Tuples can only have up to 8 elements. If there are more than 8 elements, a tuple needs to be defined as the parameter or type of return for a method.

61 Which architecture does a Dataset follow?

A Dataset is an object which follows the disconnected data architecture.

62 How do you check whether a DataReader is closed or opened?

A DataReader may be in a pending-close state, so it has not been closed, or an open state meaning the reader has been successfully opened. The “IsClosed” property is true if the DataReader is pending close and false otherwise.

63 What are the basic requirements for connection pooling?

There are two ways to fix this problem. The first is to restart the computer and retry, which will establish a new connection string for the parameters and security settings. If that doesn’t work, then you can also improve performance by closing any unnecessary programs while trying to connect because they may be attempting to open a .NET Framework on their own connection with different parameter values in order to use its processing power.

64 What is connection pooling in the .NET framework?

Connection pooling is a mechanism to reuse existing established connections rather than creating a new connection for each request. Connection pooling reduces the overhead of establishing and destroying many individual network connections, both on the client and server sides. This results in improving application performance and scalability.  A .NET developer should be familiar with this concept to design high-performing web applications.

65 What are the basic requirements for connection pooling?

Connection pooling requires the following two requirements to be met:

  • There must be more than one process to share the same connection and it often refers to a handful of parameters that all have the exact same security settings.
  • The connection string should be identical.

66 Which adapter should be used to get the data from an Access database?

OleDbDataAdapter is a DbDataAdapter type that allows you to connect to an Access database and retrieve data.

67 What are the parameters that control most of the connection pooling behaviors?

The following parameters control the connection pooling behavior:

  • Connection Timeout – Provides the duration that should elapse without any activity on downstream connections between transactions before they are released back to the free process and memory pools. This effectively extends or restricts transaction atomicity because when this event occurs, any work being done commits to stable storage and releases all locks from an instance of SQL Server.
  • Max Pool Size – The maximum number of connections that are allowed in the pool.
  • Min Pool Size – The minimum number of connections that must always be available, whether or not they have been used recently.
  • Pooling – A pool is a set of data objects or your connections that have been allocated and freed many times, rather than allocating new ones each time.

68 What do you mean by AutoPostBack?

The AutoPostBack property tells the control when to postback on its own. Setting that property to True will cause it to do so automatically whenever an event is raised.

69 Which properties are used to bind a DataGridView control?

Use the DataSource and DataMember properties in order to make a data grid view bindable.

70 What is the difference between ExecuteScalar and ExecuteNonQuery?

Executing a non-query statement via the ExecuteNonQuery method returns the number of rows affected by the last SQL statement executed, however, an execute scalar statement simply returns its output value.

71 What are the components of ADO.NET?

The components of ADO.Net are DataSet, DataReader, DataAdaptor, Command, and connection.

72 What is the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control?

In an HtmlInputCheckBox control, it is possible to select multiple items; this idea does not work for single selections in an HtmlInputRadioButton control.

73 What is encapsulation?

Encapsulation is a fundamental aspect of object-oriented programming. Children should be able to mention that encapsulation keeps specific data out of the reach of external users by binding code and data in an object, which is a single unit with complete functionality.

Encapsulation is essentially defined as the separation between the internal state of an object and its behavior. When applied, this principle means that other objects are unable to modify either the state or behaviors of an object in question

74 Explain the concept of inheritance and how it works in .NET.

The .NET framework (64-bit edition) is a windows-based set of software libraries that can be used to run and develop applications.

Candidates may be expected to demonstrate their understanding of the framework by describing it and how they would use it. One answer includes that .NET supports single inheritance, meaning a class can inherit from only one other class. Another point mentioned is that while classes are hierarchical in nature (Ford inherits from Car which inherits from Vehicle), this implies a transitive property through inheritance: for every instance of Ford, there will be 1 instance each of Car and Vehicle.

75 What is JSON data, and what is one way that .NET developers can work with JSON?

JSON (JavaScript Object Notation) is a language that organizes and stores data so it’s easy to access and read. JSON is important for developers because it allows them to manipulate JSON feeds from other sites and load them more quickly and easily than via SML/RSS feeds. Json.NET provides a way for .NET developers to define classes that parse objects and arrays from JSON text. You can also use Json.NET if you need to serialize value types into JSON text, which at this point runs on versions of the .NET Framework starting with 2-4.

Conclusion: These are our 75 best .NET interview questions for you to get started. You can always add questions or edit this list of .NET interview questions to make it your own. So, feel free to use these .NET interview questions as you prepare for a new candidate or a job with .Net skills.

As a hiring manager, you may need to tailor these questions for the responsibilities of your specific job opening. You should also allow some leeway on candidates’ answers to reflect their individual backgrounds and experience with ASP, .NET code, and various frameworks as is appropriate according to the position.

Similar Posts