Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Object-Oriented Programming with C#

You're reading from   Hands-On Object-Oriented Programming with C# Build maintainable software with reusable code using C#

Arrow left icon
Product type Paperback
Published in Feb 2019
Publisher Packt
ISBN-13 9781788296229
Length 288 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Abhishek Sur Abhishek Sur
Author Profile Icon Abhishek Sur
Abhishek Sur
Raihan Taher Raihan Taher
Author Profile Icon Raihan Taher
Raihan Taher
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Overview of C# as a Language FREE CHAPTER 2. Hello OOP - Classes and Objects 3. Implementation of OOP in C# 4. Object Collaboration 5. Exception Handling 6. Events and Delegates 7. Generics in C# 8. Modeling and Designing Software 9. Visual Studio and Associated Tools 10. Exploring ADO.NET with Examples 11. New Features in C# 8 12. Understanding Design Patterns and Principles 13. Git - The Version Control System 14. Prepare Yourself - Interviews and the Future 15. Other Books You May Enjoy

Architecture of .NET

Even though it is a decade old, the .NET framework is still well-built and makes sure to make it tiered, moduler, and hierarchical. Each tier provides specific functionalities to the user—some in terms of security and some in terms of language capabilities. The tiers produce a layer of abstraction to the end users and hide most of the complexities of the native operating system as much as possible. The .NET framework is partitioned into modules, with each of them having their own distinct responsibilities. The higher tiers request specific capabilities from the lower tiers and hence it is hierarchical.

Let's look at a diagram of the .NET architecture:

The preceding diagram depicts how the .NET framework architecture is laid out. On its lowest level, it is the operating system that interacts with the kernel APIs that are present in the operating system. The Common Language Infrastructure connects with the CLR, which provides services that monitor each code execution and managed memory, handles exceptions, and ensures that the application behaves as intended. Another important goal of the infrastructure is language inter-operability. The common language runtime is yet again abstracted with the .NET class libraries. This layer holds the binaries that the language is built on, and all of the compilers built on top of the libraries provide the same compiled code so that the CLR can understand the code and interact easily with one another.

Before going further, let's quickly look at some of the key aspects on which languages are built on the .NET framework.

Common Language Runtime

The CLR provides an interfacing between the underlying unmanaged infrastructure with the managed environment. This provides all of the basic functionalities of the managed environment in the form of garbage collection, security, and interoperability. The CLR is formed with the just-in-time compiler, which compiles the assembly code that's produced with the specific compilers to the native calls. CLR is the most important portion of the .NET architecture.

Common Type System

As there is a layer of abstraction between the language and the framework, it is evident that each of the language literals are mapped to specific CLR types. For instance, the integer of VB.NET is the same as the int of C#, as both of them point to the same type, System.Int32. It is always preferred to use language types since the compiler takes care of the mapping of types. The CTS system is built as a hierarchy of types with System.Object at its apex. The Common Type System (CTS) is divided into two kinds, one of which is value types, which are primitives that are derived from System.ValueTypes, while anything other than that is a reference type. The value types are treated differently to the reference types. This is because while allocation of memory value types are created on a thread stack during execution, reference types are always created on the heap.

.NET framework class libraries

The framework class library lies in-between the language and the CLR, and therefore any type that's present in the framework is exposed to the language you code. The .NET framework is formed with a good number of classes and structures, exposing never-ending functionalities that you, as a programmer, can benefit from. The class libraries are stored in the form of binaries that can be referenced directly from your program code.

Just-in-time compiler

.NET languages are compiled twice. During the first form of compilation, the high-level language is converted into a Microsoft Intermediate Language (MSIL), which can be understood by the CLR, while the MSIL is again compiled during runtime when the program is executed. The JIT works inside the program runtime and periodically compiles the code that is expected to be required during execution.

You have been reading a chapter from
Hands-On Object-Oriented Programming with C#
Published in: Feb 2019
Publisher: Packt
ISBN-13: 9781788296229
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 $19.99/month. Cancel anytime
Banner background image