Multiple .NET Frameworks

As briefly mentioned earlier in the chapter, there are multiple .NET frameworks. The large number of offerings is driven mainly by the desire to provide .NET implementations across multiple operating systems and, potentially, even different hardware platforms. Table 1.3 shows those that are predominant.

Table 1.3: Predominant .NET Framework Implementations

Comment Type

Description

NET 6 and later

Starting with NET 6 (following .NET Core 5.0), the Core suffix was dropped to indicate .NET Core and the .NET Framework have essentially unified into one framework.

.NET Core

A truly cross-platform and open source .NET framework that supports a highly modularized set of APIs for both the server and command-line applications.

Microsoft .NET Framework

The first of the .NET frameworks—slowly being supplanted by .NET.

Xamarin

With the release of NET 6.0, this effectively becomes a legacy mobile platform implementation of .NET that works with both iOS and Android and enables the development of mobile applications from a single code base while still enabling access to native platform APIs.

Mono

The oldest open source implementation of .NET that formed the foundation upon which Xamarin and Unity were built. Mono has been replaced by .NET Core for new development.

Unity

A cross-platform game engine used to develop video games for game consoles, PCs, mobile devices, and even websites. (The Unity engine is the first public implementation to support projections into the Microsoft Hololens augmented reality realm.)

All the samples in the book work for .NET, at a minimum, unless they specifically indicate otherwise.

note
Throughout the book, .NET framework (lowercase) refers to the framework supported by .NET implementations in general. In contrast, Microsoft .NET Framework refers to the specific .NET framework implementation that runs only on Microsoft Windows and was first released by Microsoft in 2001.

Application Programming Interface

All the methods (or more generically, the members) found on a data type such as Console are what define the Console’s application programming interface (API). The API defines how a software program interacts with a component. As such, it is found not just with a single data type, but more generically; the combination of all the APIs for a set of data types is said to create an API for the collective set of components. In .NET, for example, all the types (and the members within those types) in an assembly are said to form the assembly’s API. Likewise, given a combination of assemblies, such as those found in .NET, the collective group of assemblies forms a larger API. Often, this larger group of APIs is referred to as the framework—hence the term .NET framework in reference to the APIs exposed by all the assemblies included with the .NET. Generically, the API comprises the set of interfaces and protocols (or instructions) for programming against a set of components. In fact, with .NET, the protocols themselves are the rules for how .NET assemblies execute.

C# and .NET Versioning

Historically, the development life cycle of .NET frameworks has not always been consistent with that of the C# language; therefore, the version of the underlying .NET framework and the corresponding version of the C# language end up with different numbers. This means if you compile with the C# 11.0 compiler, it will, by default, compile against the .NET 7.0, for example. Table 1.4 is a brief overview of the C# and .NET releases for the Microsoft .NET Framework and .NET Core.

Table 1.4: C# and .NET Versions

Comment Type

Description

C# 1.0 with Microsoft .NET Framework 1.0/1.1 (Visual Studio 2002 and 2003)

The initial release of C#. A language built from the ground up to support .NET programming.

C# 2.0 with Microsoft .NET Framework 2.0 (Visual Studio 2005)

Added generics to the C# language and libraries that supported generics to the Microsoft .NET Framework 2.0.

Microsoft .NET Framework 3.0

An additional set of APIs for distributed communications (Windows Communication Foundation [WCF]), rich client presentation (Windows Presentation Foundation [WPF]), workflow (Windows Workflow [WF]), and Web authentication (Cardspaces).

C# 3.0 with Microsoft .NET Framework 3.5 (Visual Studio 2008)

Added support for LINQ, a significant improvement to the APIs used for programming collections. The Microsoft .NET Framework 3.5 provided libraries that extended existing APIs to make LINQ possible.

C# 4.0 with Microsoft .NET Framework 4 (Visual Studio 2010)

Added support for dynamic typing along with significant improvements in the API for writing multithreaded programs that capitalized on multiple processors and cores within those processors.

C# 5.0 with Microsoft .NET Framework 4.5 (Visual Studio 2012) and WinRT integration

Added support for asynchronous method invocation without the explicit registration of a delegate callback. An additional change in the framework was support for interoperability with the Windows Runtime (WinRT).

C# 6.0 with Microsoft .NET Framework 4.6 and .NET Core 1.X (Visual Studio 2015)

Added string interpolation, null propagating member access, exception filters, dictionary initializers, and numerous other features.

C# 7.0 with Microsoft .NET Framework 4.7 and .NET Core 1.1 or 2.0 (Visual Studio 2017)

Added tuples, deconstructors, pattern matching, local functions, return by reference, and more.

C# 8.0 with Microsoft .NET Framework 4.8 and .NET Core 3.0

Added support for nullable reference types, advanced pattern matching, using declarations, static local functions, disposable ref structs, ranges and indices, and async streams (although Microsoft .NET Framework 4.8 does not support the last two features).

C# 9.0 with Microsoft .NET 5.0 (most of the .NET Framework functionality was merged into .NET Core)

Added support for records, relational pattern matching, top-level statements, source generators, and function pointers.

C# 10.0 with .NET 6.0

Added simplifications included record structs, global using directives, file-scoped namespaces, extended property patterns. In addition, caller argument expressions and more were added.

C# 11 with .NET 7.0

Added support for file-scoped types, generic math support, default struct initialization, raw literal strings, generic attributes, list patterns, required members, and more.

C# with .NET 8.0

Extended use of primary constructors beyond records, and the using alias directive to any type. Added optional parameters in lambda expressions, and more.

Perhaps the most important framework feature add occurred alongside C# 6.0—that is, cross-platform compilation. In other words, not only would the Microsoft .NET Framework run on Windows, but Microsoft also provided the .NET Core implementation that would run on Windows, Linux, and macOS. This means that with the same code base it is possible to compile and execute applications that run across multiple platforms. .NET Core, renamed to simply .NET with version 5.0, is an entire SDK with everything from the .NET Compiler Platform (“Roslyn”), which itself executes on Linux and macOS, to the .NET runtime, along with tools such as the dotnet command-line utility, dotnet CLI (which was introduced around the time of C# 7.0).

{{ snackbarMessage }}
;