What is the .NET platform?

A tour of the .NET platform: the CLR runtime, the BCL library, ASP.NET, WinForms and WPF, Xamarin, and two code examples in C#.

Abstract technological illustration in shades of blue

.NET – a journey into the world of the platform that changed software development

Today’s digital world is full of platforms, languages and technologies, but one of them stands out in particular – .NET from Microsoft. This platform, created in the early 2000s, is much more than just another development tool: it is an entire universe of possibilities, built to meet the needs of programmers in every area of development – whether web applications, desktop applications, cloud services, mobile and more. But what exactly is .NET? How did it evolve, and what actually makes it one of the most popular platforms in the world?

What is hidden behind the name ”.NET”?

The name ”.NET” was not chosen by chance. Microsoft wanted to convey the idea of a “net” – Network – pointing to a connection between applications and services over the network: an approach that enables the creation of distributed, smarter and more flexible applications that can communicate with each other and share data. The platform, built from the start with a vision of integration and network-based communication, promised to make application development an easier and more focused task.

The heart of .NET – the Common Language Runtime (CLR)

Every object or line of code written in .NET runs on top of its shared runtime environment – the CLR (Common Language Runtime). The CLR is not just an engine, but a system that performs complex operations on the code and provides support for advanced features such as automatic memory management, exception handling and security.

What makes the CLR special is not only that it manages the execution of the code, but that it also does so transparently to the programmer. Any code written in a supported language (such as C#, Visual Basic, F# and others) is compiled into intermediate code (Intermediate Language, or IL), and then runs on top of the CLR. This makes a multi-language platform possible, in which code written in different languages can work together seamlessly.

Base Class Library (BCL) – the foundations of every application

Every programmer has basic, everyday operations: processing strings, working with files, mathematical calculations, network communication and more. In .NET all of these operations are bundled in the foundation library called the BCL (Base Class Library). This library is like the programmer’s toolbox – it includes essential tools that make it possible to perform a wide range of operations quickly, without rewriting code.

ASP.NET – the accelerator for web application development

Have you ever wondered how to build a dynamic website or a web service? This is where ASP.NET comes into the picture. This sub-platform is intended for developing web applications, APIs and web services. ASP.NET makes it possible to build advanced and secure websites in C#, using the same tools and libraries as .NET, which leads to harmony in development between the server side and the client side.

WinForms and WPF – the desktop opens up again

Although .NET was originally built with a web-oriented vision, it never neglected the desktop. WinForms and WPF (Windows Presentation Foundation) are two tools for building desktop applications for Windows.

  • WinForms is a classic tool for creating simple applications, very well suited to internal systems and applications with a basic graphical interface.
  • WPF offers more advanced tools that make it possible to create rich visual interfaces including images, video, 3D graphics and animations.

Xamarin – development moves to mobile

In recent years, with the rise in the use of mobile devices, a need arose for a development platform that can work with both iOS and Android. Xamarin was created exactly for this purpose. With Xamarin you can write a single codebase in C# and run it on both Android devices and iOS devices. This is a breakthrough, since it makes enormous savings in development time and costs possible.

Examples

Example 1: sending a request to a server

C#
using System;
using System.Net.Http;
using System.Threading.Tasks;

public class Program {
    public static async Task Main(string[] args) {
        using (HttpClient client = new HttpClient()) {
            string url = "https://api.weatherapi.com/v1/current.json?key=YOUR_API_KEY&q=Tel-Aviv";

            HttpResponseMessage response = await client.GetAsync(url);

            if (response.IsSuccessStatusCode) {
                string data = await response.Content.ReadAsStringAsync();
                Console.WriteLine("Data received from server:");
                Console.WriteLine(data);
            }
            else {
                Console.WriteLine("Request failed with status code: {response.StatusCode}");
            }
        }
    }
}

Example 2: accessing a database

C#
using System;
using System.Data.SqlClient;

public class DatabaseExample {
    public static void Main(string[] args) {
        string connectionString = "Data Source=localhost;Initial Catalog=MyDatabase;Integrated Security=True";
        string query = "SELECT * FROM Students";

        using (SqlConnection connection = new SqlConnection(connectionString)) {
            SqlCommand command = new SqlCommand(query, connection);

            try {
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read()) {
                    Console.WriteLine("ID: {reader["ID"]}, Name: {reader["Name"]}, Age: {reader["Age"]}");
                }
            }
            catch (Exception ex) {
                Console.WriteLine("An error occurred while accessing the database:");
                Console.WriteLine(ex.Message);
            }
        }
    }
}

In summary

Thanks to the BCL classes, such as HttpClient and SqlConnection, .NET lets us perform everyday operations efficiently and quickly. We don’t need to reinvent the wheel or build basic functions – the BCL provides the tools needed to communicate with servers, databases, files, networks and more, so that we can build complex applications much more easily.

Search and commands