Mastering C# 8.0
eBook - ePub

Mastering C# 8.0

Master C# Skills with Hands-on Code Examples

Joydip Kanjilal

Share book
  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

Mastering C# 8.0

Master C# Skills with Hands-on Code Examples

Joydip Kanjilal

Book details
Book preview
Table of contents
Citations

About This Book

Step-by-step guide written in a lucid language for mastering C# Key Features

  • Packed with plentiful code examples
  • A comprehensive guide to mastering C#
  • Discusses the OOP principles
  • Targets beginner to advanced readers of C#
  • Provides insight into the latest features of C#, including C# 8.0
  • Covers Visual Studio 2019


Description
This book starts by introducing the concepts of.NET framework. It then discusses OOP and explores how one can work with OOP in C#. There are two chapters on OOP: the first one covers the basics of object-oriented programming (OOP); and the second one delineates advanced concepts related to OOP and how they can be implemented in C#.Next, the book discusses Language Integrated Query (LINQ) and how to work with it in C#, followed by multithreading, asynchronous and parallel programming concepts with relevant code examples to illustrate the concepts covered. Generics, collections, generic collections, delegates, lambda expressions are also covered in this section.In the last section of the book, serialization, file I/O and how to work with them in C# are discussed concisely. A separate chapter on C# 8.0 is added to highlight its new features... There is an appendix chapter as well that discusses how one can get started working with Visual Studio 2019. What you will learn
By the end of reading this book, the reader will have mastered the concepts of C# programming language, and be able to build high performance, scalable and robust applications using C#. Who this book is for
This book is intended for people who are aspiring a career in.NET as well as for professionals who would like to master the concepts of C# programming language. Since this book is for beginner to advanced readers of C#, a basic knowledge of C# will be helpful. Table of Contents
1. Microsoft.NET Internals
2. Getting Started with C#
3. Object-oriented Programming - Part 1
4. Object-oriented Programming - Part 2
5. Properties and Indexers
6. Programming LINQ in C#
7. Generic Collections in C#
8. Delegates and Extension Methods
9. Exception Handling in C#
10. Asynchrony and Parallel programming
11. Multithreading in C#
12. File I/O and Serialization
13. Advanced Concepts in C#
14. New Features of C# 8.0
15. Appendix About the Author
Joydip has been the Microsoft Most Valuable Professional (MVP) in ASP.NET, consecutively for six years (2007 to 2012). With more than two decades of industry experience and 16 years of experience in Microsoft.NET, he has authored eight books and reviewed more than a dozen books. Besides, he has written more than 500 articles in leading journals and websites, including MSDN, Code Magazine, InfoWorld, SSWUG, TechTarget Inc, etc. Your Blog links: https://www.infoworld.com/blog/microsoft-coder/
Your LinkedIn Profile: https://in.linkedin.com/in/joydipkanjilal

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on ā€œCancel Subscriptionā€ - itā€™s as simple as that. After you cancel, your membership will stay active for the remainder of the time youā€™ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlegoā€™s features. The only differences are the price and subscription period: With the annual plan youā€™ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, weā€™ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Mastering C# 8.0 an online PDF/ePUB?
Yes, you can access Mastering C# 8.0 by Joydip Kanjilal in PDF and/or ePUB format, as well as other popular books in Informatica & Programmazione in C#. We have over one million books available in our catalogue for you to explore.

Information

Year
2019
ISBN
9789388511605

CHAPTER 1

The Microsoft .NET Ecosystem

Microsoft .NET Framework is a developer platform that can be used for building robust, scalable and portable applications. The first version of the Microsoft .NET Framework was released in February 2002 and since then it has matured by leaps and bounds. This book starts with a discussion on Microsoft .NET Framework.
Since C# programs would leverage the .NET Framework, a good knowledge of what the underlying platform is all about and how its components work is imperative for building efficient applications. This chapter discusses the concepts related to Microsoft .NET Framework, its components, memory management, etc. In order to be a proficient programmer in C#, one must understand the internals of .NET as well. Letā€™s take a round of briefing on the Microsoft .NET Framework before we start learning C# in the next chapter.

Structure

In this chapter, we will discuss the following points:
  • Introduction to Microsoft .NET
  • Common Language Runtime
  • Framework Class Library
  • Common Language Specification
  • Common Type System
  • Common Intermediate Language
  • Components of Microsoft .NET Framework
  • Garbage collection
  • The Dynamic Language Runtime

Objective

After reading this chapter, the reader will be able to:
  • Understand the components of .NET Framework
  • Learn how the garbage collector works in .NET.
  • Understand why the Common Intermediate Language is needed
  • Understand the Dynamic Language Runtime

Introduction to Microsoft .NET

.NET Framework is a popular software development platform created by Microsoft. It has been around for a long time now and can be used to build windows applications, web services, and web-based applications. The .NET Framework primarily runs on Windows. However, you can use .NET Core, a light-weight framework, if you have to build and run your applications on Linux or Mac as well. .NET Core is a free, modular, open-source framework for Windows, Linux, and macOS operating systems. It is a platform-independent successor to .NET Framework that has been released under the MIT license.
The .NET Framework provides the following benefits:
  • Portability
  • Cross-Language Integration
  • Interoperability
  • Base Class Library
  • Security

Evolution of .NET framework

Figure 1.1 illustrates the evolution of .NET Framework from version 2.0:
Figure 1.1: The evolution of .NET over the years
Note that Figure 1.1 shows the evolution of .NET till .NET Framework 4.5 only. The major releases of .NET Framework after .NET Framework 4.5, with their features, are as follows:
  • .NET Framework 4.6: This version introduces new features and enhancements in cryptography, ADO.NET, WPF, profiling, NGen, and Windows Workflow Foundation (WWF).
  • .NET Framework 4.7: This version introduces new features and enhancements in base classes, networking, ASP.NET, Windows Communication Foundation (WCF), Windows Forms, and Windows Presentation Foundation (WPF).
  • .NET Framework 4.8: This version introduces new features and enhancements in the areas ofbase classes, WCF, WPF, and Common Language Runtime (CLR).

Common Language Runtime

The Common Language Runtime (CLR) is a runtime engine that is responsible for executing your programs, code verification, type safety, memory allocation, garbage collection, security, and many more. It provides several services, which includes:
  • Just-in-time compilation
  • Garbage collection
  • Code access security
  • Memory management
  • Code verification
Figure 1.2 depicts the components of .NET Framework.
Figure 1.2: Components of .NET Framework

Common Intermediate Language

The Common Intermediate Language (CIL), formerly known as Microsoft Intermediate Language (MSIL), is a platform-independent language into which source code that is compiled in the .NET environment is written. It is a set of instructions that are platform independent and is generated by the compiler from the source code. At runtime, the CIL is converted into a machine code by the Just-in-Time (JIT) compiler. In other words, the JIT compiler converts the CIL into a machine code specific to the target environment, that is, the environment in which the application needs to execute. Figure 1.3 shows how this entire process works:
Figure 1.3

Dynamic Language Runtime

While the CLR provides services such as, a common type system, JIT, garbage collection, and many more, the Dynamic Language Runtime (DLR) runs on top of the CLR and offers services for dynamic languages. These include: dynamic types, dynamic method dispatch, code generation, and more.
Figure 1.4 shows how CLR and DLR are related:
Figure 1.4: The Dynamic Language Runtime (DLR)
The DLR was first introduced in .NET 4.0, and since then it has been a part of .NET Framework. The addition of a powerful feature, dynamic keyword, in .NET 4.0 enhanced the capabilities of C# programming language. Essentially, the dynamic keyword is used to skip the compile-time type checking. When you have a method with a dynamic parameter, the method can accept any type at runtime. Weā€™ll learn more about the dynamic keyword later in this book.

Framework Class Library

The .NET Framework Class Library (FCL) is a comprehensive collection of reusable classes, interfaces, and data types that provide several services. Note that the FCL provides the base on top of which applications and components written in .NET are built.
The services provided by the FCL include the following:
  • File handling
  • Exceptions
  • Remoting
  • Sockets
  • Database access
  • XML
  • Web services

Common Type System

The Common Type System (CTS) is a standard that is used to define how the .NET types are represented in the memory. The CTS enables multiple languages targeted at the .NET Framework to co-exist. It provides support for two types, which are explained inthe next section.

Value types and reference types

The CTS provides support for two types. These include: value types and reference types. While value types are stored in the stack, reference types are stored in the managed heap. The primitive data types, such as char, int, and etc, are examples of value types. Other examples of value types include: struct and enum. Refer to Figure 1.5 for better understanding:
Figure 1.5: Common Type System
Hereā€™s the list of value types in .NET:
  • bool
  • byte
  • char
  • decimal
  • double
  • enum
  • float
  • int
  • long
  • sbyte
  • shor...

Table of contents