.NET Framework Programming Technical Interview Questions

What is .NET Framework?

.NET Framework is a programming infrastructure that was developed by Microsoft. Its primary function is to build, deploy and run applications and services that use .NET technologies. This includes desktop applications, as well as web services. It is intended to run primarily on Microsoft Windows, but does have some support for other platforms.

The .NET Framework contains three major parts: the Common Language Runtime (CLR), the Framework Class Library (FCL), and ASP.NET.

The FCL is a large class library that provides language interoperability across several programming languages. Basically this means that each language can use code written in other languages. The CLR is an application virtual machine. It provides services such as security, memory management, and exception handling. The FCL and CLR together make up the .NET Framework.

ASP.NET is commonly clubbed together with the .NET Framework, as it has been constantly released along with it. ASP.NET is an open-source server-side web application framework. It is primarily designed for web development. It allows programmers to build dynamic web pages, web sites, web applications and web services.

What are the main components of .NET Framework?

There are two main components of .NET Framework: Common Language Runtime (CLR) and .Net Framework Class Library.

The Common Language Runtime (CLR) provides the runtime environment where all the .NET programs run. The CLR provides memory management and thread management for the programs that are running under it. The code that runs under CLR is called Common Language Runtime (CLR).

.Net Framework Class Library, also known as Base Class Library, is a large class library that provides language interoperability across several programming languages. Basically, it allows the use of code written in other programming languages.

Some of the other components of .NET Framework include:

  • Dynamic Language Runtimes (DLR)
  • Application Domains
  • Runtime Host
  • Common Type System
  • Metadata and Self-Describing Components
  • Cross-Language Interoperability
  • NET Framework Security

List the new features added in .NET Framework 4.0

According to Microsoft, the following are the new features that are added in .NET Framework 4.0. One of the primary things is the improved security in the .NET.

  • Security Changes
  • Application Compatibility and Deployment
  • Core New Features and Improvements
  • Managed Extensibility Framework
  • Parallel Computing
  • Networking
  • Web
  • Client
  • Data
  • Windows Communication Foundation
  • Windows Workflow Foundation
  • New namespaces, new types, and new members added to existing types

These two are optional updates to .NET Framework 4.0, which are also available for those that want it.

  • Visual Studio 2010 Service Pack 1 (SP1), which includes an update to the .NET Framework 4.
  • Update 4.0.3 for Microsoft .NET Framework 4 and earlier updates, which include several enhancements for the .NET Framework.
List the new features added in .NET Framework 4.6

Microsoft has added the following new features in the .NET Framework version 4.6.

  • Character categories
  • Cryptography
  • SqlClient
  • Windows Communication Foundation
  • Windows Presentation Foundation (WPF)
  • Windows Workflow Foundation (WF)
  • ClickOnce
  • Converting Windows Forms and WPF apps to UWP apps
  • Debugging improvements
What is an IL?

IL stands for Intermediate language. It is also known as Common Intermediate Language (CIL) and Microsoft Intermediate Language (MSIL).It is an object-oriented programming language that is meant to be used by the compilers for the .NET Framework.

The IL is designed to be used before static or dynamic compilation to machine code. The primary purpose of IL is to generate CPU independent partially compiled code which is the output of compilation of the source code written in any .NET programming language. This means that it can be executed on any computer architecture supported by the JIT compiler.

IL is a stack-based assembly language. This means that it gets converted to bytecode during execution of a virtual machine. The benefit of IL is that as that there is no need to learn syntax, as it automatically generates complied code. In fact that language is meant to be understood by the computer only, and not by the user.

What is Manifest?

A manifest, officially called the .Net Assembly Manifest, is a text file that contains the assembly metadata. It is a collection of data that describes how the elements in the assembly relate to each other. The metadata can then be used to specify the assembly's version requirements, the security identity, as well as define the scope of the assembly and resolve references to resources and classes.

The manifest can be stored in either a PE file, that is as a .exe or .dll, either with Microsoft Intermediate Language (MSIL) code or as a standalone PE file that contains only the assembly manifest information.

What are code contracts?

Code Contracts are type of methods. They are static library methods that are used in the .NET program to specify the code’s behavior. Basically, think of it as a contract for the code. It defines what the code must do and how must it do it. They specify preconditions, post conditions, and object invariants in the code. Preconditions are requirements that must be met when entering a method or property. Post conditions are expectations that exist at the time the method or property code exits. Object invariants describe the expected state for a class that is in a good state.

The benefits of code contracts include improved testing, automatic testing tools, static verification, and reference documentation. These code contracts are primarily utilized by the runtime checking and static checking tools. The code contracts can be found in the System.Diagnostics.Contracts namespace.

Name the classes that are introduced in the System.Numerics namespace

There are two new classes that are introduced in the System.Numerics namespace. They are the following: BigInteger and Complex.

1. BigInteger – The BigInteger structure is an non-primitive integral type. It is primarily is used to hold a value of any size, and can support arbitrarily large integers. It has no lower and upper limit, which makes it possible to perform arithmetic calculations with very large numbers, including numbers which cannot hold by double or long.

2. Complex – The Complex structure represents a complex number. It allows for different arithmetic operations with complex numbers. A complex number is represented in the form a + bi, where a is the real part, and b is the imaginary part.

The System.Numerics namespace also contains the SIMD-enabled vector types, such as Vector4, Matrix3x2, Plane, and Quaternion.

What is Managed Extensibility Framework?

The Managed Extensibility Framework, commonly referred to as MEF, is a component .NET Framework 4.0. It is a library that was introduced to create lightweight, extensible applications. It is basically used to plug-in components to an already running application.

Primarily any application that wants to support a plugin model needs to create its own infrastructure from scratch. However, the benefit of MEF is that it allows an application developer to discover and use extensions without requiring any configuration.

MEF also lets extension developers easily encapsulate code and avoid fragile hard dependencies. It allows extensions to be reused within applications, as well as across applications. It also allows tagging of extensions with additional metadata win order to facilitate rich querying and filtering.

What are memory-mapped files?

A memory-mapped file is a type of file that contains the contents of a file in virtual memory. Basically, it allows for mapping between a file and memory space. This is turn allows an application, including multiple processes, to modify the file by reading and writing directly to the memory. Hence, it allows applications to treat the mapped portion as if it were primary memory.

There are two types of memory-mapped files:

Persisted memory-mapped files - associated with a source file on a disk. Here, the data is saved to the source file on the disk after the last process has finished working with the file. Suitable for working with extremely large source files.

Non-persisted memory-mapped files - are not associated with a file on a disk. After the last process has finished working with the file, the data is lost and the file is reclaimed by garbage collection. Suitable for creating shared memory for inter-process communications (IPC).

What is Common Type System (CTS)?

The Common Type System (CTS) is a standard that is primarily used for defining and using data types in the .NETframework. A data type is a definition of a set of values. The CTS specifies how type definitions and specific values of types are represented in computer memory. These data types in turn are used and managed by the run time to facilitate cross-language integration.

The benefit of CTS is that it allows programs written in different programming languages to easily share information. It also provides an object-oriented model that supports the complete implementation of many programming languages.

THE CTS supports two general categories of types:

Value types – contain data and instances of value types that are either allocated on the stack or allocated inline in a structure. These can be implemented by the runtime, can be user-defined, or through enumerations.

Reference types – store a reference to the value's memory address. Are allocated on the heap. These can be self-describing types, pointer types, or interface types. The type can be determined from values of self-describing types. Are user-defined classes, boxed value types, and delegates. Are further split into arrays and class types.

What is side-by-side execution?

As the name suggests, side-by-side execution refers to the ability to run two or more applications side by side, i.e. the ability to run multiple versions of an application or component on the same computer. If there are multiple versions of the common language runtime, and/or multiple versions of applications and components that use a version of the runtime, they can be run on the same computer at the same time.

Side-by-side execution has certain benefits, such as the fact that it uses strong-named assemblies, which are used to bind type information to a specific version of an assembly. It also utilizes version-aware code storage in the global assembly cache. Additionally, it allows one to create applications and components that execute in isolation, which is an essential component of side-by-side execution.

However, it should be noted that while there is the ability to create side-by-side applications, side-by-side execution is not automatic.

Can two applications, one using private assembly and the other using the shared assembly be stated as side-by-side executables?

No, it is not possible to run two applications, one using private assembly and the other using the shared assembly side to side.

The reason for this is that while side-by-side execution enables the running of multiple versions of an application or component and CLR on the same computer at the same time, versioning is applicable only to shared assemblies and not to private assemblies. Hence, it is not possible to run two applications, one using private assembly and the other using the shared assembly be stated as side-by-side executables.

Which method do you use to enforce garbage collection in .NET?

In order to enforce garbage collection in .NET, the following method is used:

The System.GC.Collect() method.

The garbage collection GC class provides the GC.Collect method. This method can be used to give the application some direct control over the garbage collector. However, it is recommended that one should avoid calling any of the collect methods, instead allowing the garbage collector to run independently. The reason for this is that the garbage collector is better at determining the best time to perform a collection.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.