I am pleased to announce that my new book, Learn C# Programming, that I co-authored together with Raffaele Rialdi (Microsoft MVP/speaker) and Ankit Sharma (C# Corner MVP/Google Dev Expert/speaker) has been published at PacktPub. The book can be ordered at PacktPub and Amazon (ISBN 9781789805864).
This book is primarily intended for people that want to learn to program in C# for .NET. This book will not teach you the basics of programming but it will teach you the C# language from the very basics to the most advanced topics, and to the latest in C# 8, which is the current version of the language. However, if you are an experienced C# programmer, but want to learn the latest features from C# 8 or how to work with .NET Core, target multiple platforms, and migrate from .NET Framework, this book should be handy for you too.
We start with the very basic such as data types, variables, strings, arrays, operators, control statements, and loops. Then, we progress to learn about object-oriented programming and all related aspects such as classes, structures, interfaces, and inheritance. We then get into generics and generic collections, functional programming and LINQ, reflection and dynamic programming, multi-threading and asynchronous programming. We also cover topics such as pattern matching and regular expressions, tuples, delegates and events, resource management, P/Invoke, files and streams, XML and JSON serialization, error handling, and many others. These include the important topics of what’s new in C# 8, the .NET Core 3 framework and how to use the dotnet command-line interface (CLI), consume NuGet packages, develop for Linux, and migrate apps built with .NET Framework. Lastly, we discuss unit testing and learn how to write unit tests and data-driven unit tests for C# using the tools available in Visual Studio.
The following list includes things that you will learn from the book:
- All the language features that enable you to build C# apps for desktop, server, web, cloud, and mobile
- All the new features from C# 8
- Utilize LINQ to uniformly query various sources of data
- Functional programming techniques such as partial function application, currying, closures, monoids, and monads
- Discover how to use attributes and reflection to build extendable applications
- Work with XML and JSON
- Write asynchronous code with the async-await pattern
- Call system APIs with P/Invoke
- Work with regular expressions
- Interop with COM and dynamic languages using the dynamic type
- Error handling and best practices for working with exceptions
- Use .NET Core tools to create, compile, and publish your applications for multiple platforms
- Create unit tests with Visual Studio and the Microsoft unit testing frameworks
A more detailed description of the content of each chapter is given below:
- Starting with the Building Blocks of C#, gives an introduction to the language, its history, and its relationship with the Common Language Infrastructure and .NET Framework, as well as providing an introduction to the family of .NET frameworks used today. At the end, you learn about assemblies, how to create a project in Visual Studio, and how to write a Hello World program in C#.
- Data Types and Operators, walks you through the basic elements of the language, including the built-in data types, variables and constants, reference and value types, nullable types, and array types, as well as type conversions and built-in operators.
- Control Statements and Exceptions, looks in depth at how to write selection statements and loops and briefly at working with exceptions.
- Understanding the Various User-Defined Types, provides information about classes, fields, properties, methods, constructors, how to pass arguments to methods, what access modifiers are, and other aspects related to classes. Toward the end, you will learn about structures and how they compare to classes, as well as enumerations.
- Object-Oriented Programming in C#, continues on the foundation built with the previous chapter and teaches you the core pillars of object-oriented programming and how you achieve them using C# language features such as interfaces, virtual members, method overloading, and others.
- Generics, covers all the aspects of generic programming in C# and teaches you how to write generic types and methods and use constraints for type parameters.
- Collections, provides a walk-through of the generic collections from the .NET base class library that you typically use when writing C# programs. The chapter ends with an overview of the concurrent collections used in multithreading scenarios.
- Advanced Topics, contains a variety of more advanced features, such as delegates and events, tuples, extension methods, pattern matching, and regular expressions.
- Resource Management, explains how the garbage collector works and how you should handle resources deterministically. Also, in this chapter, you learn how to make system or, in general, native API calls with Platform Invocation Services, as well as how to write unsafe code.
- Lambdas, LINQ, and Functional Programming, provides an overview of functional programming concepts and details pertaining to lambda expressions in C#. You learn how to uniformly query various data sources using Language Integrated Query (or LINQ). At the end of the chapter, we cover several typical functional programming concepts: partial function application, currying, closures, monoids, and monads and how they work in C#.
- Reflection and Dynamic Programming, teaches you what reflection services are and how they can be used to write extensible applications, how to dynamically load assemblies and execute code, how to use attributes, and how to use the Dynamic Language Runtime and the dynamic type to interop with dynamic languages.
- Multithreading and Asynchronous Programming, provides an in-depth look at threads, tasks, and synchronization mechanisms and uncovers the details of the asyncawait pattern for writing asynchronous programs in C#.
- Files, Streams, and Serialization, explains how to work with paths, files, and directories, and how to use streams for reading and writing data from and to a variety of storage options, such as files and memory. In the second part of the chapter, you will learn about data serialization with XML and JSON.
- Error Handling, builds on the concepts concerning exception handling introduced in Chapter 3, Control Statements and Exceptions and teaches you the inner workings of exceptions and how exception handling differs from error handling. You will learn valuable information about debugging and monitoring as well as best practices for working with exceptions.
- New Features of C# 8, covers in detail all the new language features introduced in C# 8, including nullable reference types, async streams, ranges and indices, pattern matching, and default implementations of interface members.
- C# in Action with .NET Core 3, teaches you about using the .NET CLI for building .NET Core applications, how you can target and develop for Linux, what .NET Standard is and how it can help application design, how to consume NuGet packages, and how you can migrate .NET Framework applications to .NET Core.
- Unit Testing, covers unit testing, the Microsoft tools for unit testing your C# code, how to create unit testing projects using Visual Studio, and how to write unit tests and data-driven unit tests.
I hope you will enjoy the book and it will help you to master the C# language.