What is .NET?
.NET is a framework created by Microsoft for developing applications. .NET can create many different types of applications, such as desktop applications, Windows Store applications, cloud/web applications, web API applications and so on. The .NET framework has been designed so that it can be used from any language, including C#, C++, Visual Basic, JScript and even COBOL. Not only do these languages have access to the .NET framework, they can communicate with each other.
The .NET framework itself consists of a huge library of code that you use from your own client language, such as C#, using object oriented (OOP) techniques. The library is categorized into different modules that serve a specific purpose. For example, one module contains the building blocks to create Windows applications, another for network applications and another for developing Web applications. Some modules have submodules, such as the Web API module that is a submodule of the Web module.
The .NET Framework library defines some basic types. There are simple types and complex types. Simple types are also referred to as primitives and include types such as numbers and Boolean. The Common Type System (CTS) defines basic types (e.g. 32-bit signed integer) facilitating inter-operability between programming languages.
.NET Framework also provides a Common Language Runtime (CLR) that’s responsible for the execution of all applications developed using .NET library.
Writing Applications
You write code in any of the supported languages using the .NET code library in Visual Studio. You can download Visual Studio Community for free. It is a powerful integrated development environment (IDE) supporting C#, C++, VB, Jscript, COBOL etc. C# is converted into native code that the OS understands by compiling the code in 2-stage process.
- compile code into Common Intermediate Language (CIL) which is not C# or OS-specific. CIL’s name: Microsoft Intermediate Language
- The Just-In-Time (JIT) compiler will compile CIL into native code specific to the OS and hardware.
Only now can the OS execute the application. When you compile an application the CIL code is stored in an assembly which includes executables (exe), libraries (dll), meta information and resources (pictures, movies and sound files). The Global Assembly Cache (GAC) contains reusable code that your team may access.
Managed Code – The CLR looks after your applications by managing memory, handling security, cross-language debugging, garbage collection and so on. With C# you can only write managed code. With C++ you may write unmanaged code (not under the CLR). C# is the only language developed from the ground up to work with .NET and can make use of every .NET feature there is. .NET includes ADO.NET, ADO.NET Entity Framework and LINQ (Language Integrated Query), graphics tools, complex math tools and many others.
The above diagram is in the public domain. By Jarkko Piiroinen (Own work) [Public domain], via Wikimedia Commons.
Dynamic Language Runtime (DLR)
In .NET version 4 Microsoft added a new component called DLR. DLR sits on top of CLR to give C# dynamic language capabilities. By design, C# is not a dynamic programming language.