Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Learn C# Programming

You're reading from   Learn C# Programming A guide to building a solid foundation in C# language for writing efficient programs

Arrow left icon
Product type Paperback
Published in Apr 2020
Publisher Packt
ISBN-13 9781789805864
Length 636 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (4):
Arrow left icon
Marius Bancila Marius Bancila
Author Profile Icon Marius Bancila
Marius Bancila
 Tripathi Tripathi
Author Profile Icon Tripathi
Tripathi
 Rialdi Rialdi
Author Profile Icon Rialdi
Rialdi
Ankit Sharma Ankit Sharma
Author Profile Icon Ankit Sharma
Ankit Sharma
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Chapter 1: Starting with the Building Blocks of C# 2. Chapter 2: Data Types and Operators FREE CHAPTER 3. Chapter 3: Control Statements and Exceptions 4. Chapter 4: Understanding the Various User-Defined Types 5. Chapter 5: Object-Oriented Programming in C# 6. Chapter 6: Generics 7. Chapter 7: Collections 8. Chapter 8: Advanced Topics 9. Chapter 9: Resource Management 10. Chapter 10: Lambdas, LINQ, and Functional Programming 11. Chapter 11: Reflection and Dynamic Programming 12. Chapter 12: Multithreading and Asynchronous Programming 13. Chapter 13: Files, Streams, and Serialization 14. Chapter 14: Error Handling 15. Chapter 15: New Features of C# 8 16. Chapter 16: C# in Action with .NET Core 3 17. Chapter 17: Unit Testing 18. Assessments 19. Other Books You May Enjoy

The .NET family of frameworks

.NET is a general-purpose development platform developed by Microsoft for writing a variety of types of applications for desktop, cloud, and mobile. .NET Framework was the first implementation of the CLI but, over time, a series of other frameworks have been created, such as .NET Micro Framework, .NET Native, and Silverlight. While .NET Framework works on Windows, other current implementations, such as .NET Core and Mono/Xamarin, are cross-platform and run on other operating systems, such as Linux, macOS, iOS, or Android.

The following screenshot shows the main characteristics of the current top .NET frameworks. .NET Framework is intended for developing .NET applications for Windows and is distributed with the operating system. .NET Core, which is cross-platform and open source, is optimized for modern application requirements and developer workflows and is distributed with the application. Xamarin, which uses a Mono-based runtime, is also cross-platform and open source. It is intended for developing mobile applications for iOS, macOS, Android, and Windows, and is distributed with the application:

Figure 1.5 – A diagram with the main characteristic of the most important .NET frameworks

Figure 1.5 – A diagram with the main characteristic of the most important .NET frameworks

All of these implementations are based on a common infrastructure that includes languages, compilers, and runtime components and supports a variety of application models, some of which are shown in the following screenshot:

Figure 1.6 – A high-level diagram of the .NET frameworks infrastructure and the application models they support

Figure 1.6 – A high-level diagram of the .NET frameworks infrastructure and the application models they support

Here, you can see that each framework resides on top of the common infrastructure and provides a set of base libraries as well as different application models.

.NET Framework

.NET Framework was the first implementation of the CLI. It is the primary development platform for Windows Server and client developers. It contains a large class library that supports many types of applications. The framework is distributed as a part of the operating system and as a result, new versions are serviced through Windows Update, although standalone installers are also available. Initially, .NET Framework was proprietary software developed by Microsoft. In recent years, parts of .NET Framework have been open-sourced.

The following table shows the history of .NET Framework, as well as the major features available in each release:

In the future, Microsoft intends to unify all .NET frameworks into a single one. At the time of writing this book, this is planned to be named .NET 5.

.NET Framework includes the Common Language Runtime (CLR), which is the execution engine of the framework that provides services such as memory management, type safety, garbage collection, exception handling, thread management, and others. It also includes an implementation of the CLI foundational standard libraries. The following is a list of the components of the standard libraries (although not all of them):

  • Base Class Library (BCL): It provides types to represent the CLI built-in types, simple file access, custom attributes, string handling, formatting, collections, streams, and others.
  • Runtime Infrastructure Library: It provides services to dynamically load types from a stream and other services that allow the compiler to target the CLI.
  • Reflection Library: It provides services that make it possible to examine the structure of types at runtime, instantiate objects, and invoke methods.
  • Network Library: It provides networking services.
  • Extended Numerics Library: It provides support for floating-point and extended-precision data types.
  • Parallel Library: It provides parallelism in simple forms.

Apart from these libraries, the .NET Framework Class Library (FCL) includes many other libraries, such as WPF, WinForms, WCF, LINQ, and others. Most of these are in the System.* or Microsoft.* namespaces.

A key aspect of developing in C# for the .NET platform is how memory is managed. In general, developers do not have to worry about the lifetime of objects and the disposal of memory. Memory management is automatically done by the CLR through the Garbage Collector (GC). The GC handles the allocation of objects on the heap and the disposal of memory when heap objects are no longer used.

The garbage collection is a non-deterministic process because it happens on a per-need basis and not at some deterministic moments. A detailed description of the way the garbage collection works is provided in Chapter 9, Resource Management.

.NET Core

.NET Core is a new implementation of the CLI that is cross-platform, open source, and modular. It is intended for developing a variety of applications, such as web apps, micro-services, libraries, or console apps that run on Windows, Linux, and macOS. The .NET Core framework is packaged using NuGet; as a result, it is either compiled directly into an application or put into a folder inside the application. Therefore, .NET Core applications distribute the framework components directly, although a cache system for a centralized deployment, called runtime package store, is also available starting with version 2.0.

The implementation of the VES for .NET Core is called CoreCLR. Similarly, the implementation of the CLI foundational standard libraries is called CoreFX.

ASP.NET Core is a part of .NET Core but also runs on the .NET Framework CLR. However, an ASP.NET Core app is cross-platform only when targeting .NET Core.

With the release of version 3.0 in September 2019, developers can create web apps, micro-services, desktop applications, machine learning, and AI applications, IoT applications, libraries, and console applications using .NET Core.

You will learn more about .NET Core in Chapter 16, C# in Action with .NET Core 3.

Xamarin

Xamarin is a CLI implementation based on Mono, which is a cross-platform, open source .NET framework. In general, Mono APIs followed the progress of .NET Framework and not .NET Core. The framework is intended for writing mobile applications that can run on iOS, Android, macOS, and Windows devices.

Applications developed with Xamarin are native, which provides similar performance to those developed with Objective-C or Swift for iOS and Java or Kotlin for Android. Xamarin also provides facilities to directly invoke Objective-C, Java, C, and C++ libraries.

Xamarin applications are written in C# and use the .NET Base Class Library. They can share most of the code, with only a small portion needed to be platform-specific.

Detailed information about Xamarin is beyond the scope of this book. If you want to learn more about this implementation, you should use additional resources.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime
Visually different images