Post

DOTNET - Introduction to .NET

Introduction to .NET

  • .NET is a free, open-source, cross-platform framework for building many types of applications.
    • Free means you can use it without paying a licensing fee.
    • Open-source means you can view the source code and contribute to the project.
    • Cross-platform means you can run your code on Windows, macOS, and Linux.
  • .NET is an ecosystem for application development
  • In other words, .NET is a collection of many parts and people that together create a powerful environment for building applications.

.NET Compiler, Runtime and Assembly

  • Software developers use .NET languages like C# and F# to write source code.
  • Before software developers can run their code, they must first compile it.
  • The .NET compiler is a program that converts the source code (in any supported programming language) into a portable language called intermediate language (IL).
  • The .NET compiler saves the IL code into a file called a .NET assembly.
  • By compiling the code into an intermediate format, you can use the same code base wherever you run the code, whether on Windows or Linux, or on 32-bit or 64-bit computer hardware.
  • The .NET runtime is an execution environment for your compiled .NET assembly.
  • In other words, the .NET runtime is what executes and manages your application as it runs on a host operating system.

C# and .NET

  • Sometimes people think that the C# programming language is .NET.
  • However, C# and .NET are distinct.
  • C# is a programming language syntax.
    • As part of the syntax, you can reference and call methods defined in .NET code libraries, or assemblies.
    • Next, you’ll use the C# compiler that’s installed with the .NET SDK to create a .NET assembly from your C# code.
  • The .NET runtime then runs the .NET assemblies.
  • These distinctions are important concepts as you learn more about .NET and C#.

.NET Code Libraries and Application Frameworks

  • All software is built in layers, meaning software runs at various levels of abstraction on a computer:
    • At the lowest level, software communicates directly with your computer’s hardware. It controls the flow of data on the motherboard, processors, memory, and hard drives.
    • At the next level, software allows the end user to provide instructions through an operating system.
    • Above the previous level, software like .NET provides a way for you to develop and run applications.
    • At the final level, application frameworks and libraries of functionality allow you to quickly build rich applications with less effort than older development methods.

.NET Code Libraries

  • A code library encapsulates functionality for a specific purpose into a single assembly.
  • For .NET, thousands of libraries are available.
  • These libraries can be first-party or third-party, and can be commercial or open source.
  • The libraries provide a vast array of functionality you can use in your applications.
  • You merely reference those assemblies and call the methods you need.
  • In this way, as a developer, you build on the work of other software developers.
  • You save time and energy because you don’t have to build and maintain every feature yourself.

.NET Application Frameworks

  • An application framework combines several related libraries, along with starter projects, file templates, code generators, and other tools.
  • You can use these resources to build entire applications for a specific purpose.
  • These application frameworks are known as app models.
  • For example, .NET application frameworks are available for popular app models like web development, desktop and mobile development, and game development.
  • You can install the .NET SDK directly or by installing Visual Studio 2022.
  • The .NET SDK preinstalls a comprehensive set of libraries and application frameworks called the base class library.
  • You can use this library of code in your programs regardless of the platform or app models you want to build.
  • For other third-party libraries, developers use package managers like NuGet to find and integrate code libraries from package repositories like the NuGet Gallery.

What are the major app models?

  • You might wonder which frameworks support which app models.
  • Use the following table to map an app model to a .NET framework.
App Model.NET FrameworkNotes
WebASP.NET CoreThe framework for building server-side logic.
WebASP.NET Core MVCThe framework for building server-side logic for web pages or web APIs.
WebASP.NET Core Razor PagesThe framework for building server-generated HTML.
Web clientBlazorBlazor is a part of ASP.NET Core. Its two modes allow for either Document Object Model (DOM) manipulation via sockets as a communication vehicle for running server-side code, or a WebAssembly implementation for running compiled C# on a browser.
Desktop.NET for MacAllows .NET developers to build apps for Mac devices with native UI and API access.
DesktopWinFormsA framework for building “battleship gray” Windows-style applications.
DesktopWindows Presentation Foundation (WPF)A framework for building dynamic desktop applications that conform to different form factors. WPF allows form elements to perform movement, fades, glides, and other effects with the help of a rich library of animations.
Mobile.NET for AndroidAllows .NET developers to build apps for Android devices with native UI and API access.
Mobile.NET for iOSAllows .NET developers to build apps for iOS and iPadOS with native UI and API access.
Multi-Platform App UI.NET MAUIThe premier way to build apps for iOS, Android, Mac, and Windows from a single shared code base with native UI and access to native APIs.

Find solutions and answers in documentation and tutorials

  • Microsoft actively provides a rich set of documentation, tutorials, and training.
  • You’ll find learning materials in popular modalities to help you at each step in your learning process.
  • The following table features a few great resources you might want to bookmark and come back to.
Resource NameDescription
Microsoft LearnProvides quick-start tutorials and definitive reference documentation.
Patterns and PracticesHelps developers and software architects find solutions to common application development needs. Resources often transcend the low-level details of writing code and delve into choosing products and services that enable seemingly infinite scalable architectures.
.NET VideosProvides video tutorials from the .NET team. These videos walk developers through common usage scenarios.
Get Started with C#Provides hands-on labs to help you build your skills by combining instruction, exercises, media, knowledge checks, and a means of tracking your progress.

A brief history of .NET

  • The original .NET Framework was first released in early 2002. Since then, many updates and much more functionality have followed. After years of enhancements and new features, the original .NET Framework, especially key code libraries, grew significantly.

  • After 2002, Microsoft worked to make a version of .NET that had cross-platform compatibility. The goal was to allow developers to write one code base and use it across macOS, Linux, and Windows operating systems.

  • Through these efforts, .NET Core was introduced around 2014. Microsoft has maintained the original .NET Framework, but new features and improvements are reserved for .NET Core. Core was later dropped from the name. The next major versions are .NET 5, .NET 6, .NET 7, .NET 8, and so on. Versions are generally released each November.

  • Why is the .NET history worth mentioning? Because you’ll likely find blog posts, videos, and source code that targets the original .NET Framework. In some cases, the instructions or code still work, but in other cases, you might need to make adjustments to fit the new .NET.

This post is licensed under CC BY 4.0 by the author.