Vaskaran Sarcar
Kolkata, West Bengal, India
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/978-1-4842-5933-7 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-5933-7 e-ISBN 978-1-4842-5934-4
https://doi.org/10.1007/978-1-4842-5934-4
Vaskaran Sarcar 2020
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Foreword
A tool is only as good as its user!
Building on this truth, using a programming language is similar in that its effectiveness is only as good as the knowledge and skill of the person using it. This book is for people who have a basic understanding of how to write a C# program but want to leverage more advanced constructs for building optimized, scalable, long-lasting solutions.
C# has come a long way from being a Microsoft Windows tool a few years ago. Now it is also used in much larger ecosystems, such as Mac and Linux. This makes the code a lot more portable. Microsoft also integrated their recent acquisition of Mono into their portfolio, so that a coder can target the code to run on multiple platforms. As the popularity of the language increases, it is important that coders learn about its advanced features to make the best use of the framework.
I have spent a good part of my career programming and reviewing others C# code. I realized that many developers do not use the language effectively because they are not aware of the more useful features that it has to offer. This book serves as a guide for exactly thatlearning the more advanced concepts.
Today, it is more important than ever to not only consider how quickly a solution can be developed, but also about how the solution can be reused across multiple platforms and fine-tuned for each platform. Knowing advanced topics helps developers to easily fine-tune to the environment that their code runs on, so that they are optimized for that environment.
The book starts with concepts such as delegates and events. It then goes into finer detail, including programming with generics, multithreading, database connections, and more. In each chapter, Vaskaran explains the construct in a very simple way, with examples, and then proceeds to a Q and A session. It almost mimics a classroom session. This style engages the reader in learning the topic and answers questions. This is an excellent way to absorb the fundamental concepts and to ensure understanding them.
Vaskaran has worked with me for many years and has always been very passionate about C# and the nonfunctional aspects of programming, such as memory management, performance, and so forth. In this book, he has done a commendable job with putting together great examples that clearly explain the concepts. I am sure that this book will propel C# developers to the next level in a very short time.
Deepak Seshadri
Performance Architect
Printer Firmware, HP Inc.
Introduction
This book is an introductory guide to advanced programming in C#. The examples and code have been deliberately kept simple to allow you to concentrate on understanding important concepts in depth.
In 2015, I wrote C# Basics: Test your Skill, which covered fundamental concepts in C#. In 2018, the book was further enhanced and Interactive C# was published. Immediately after its release, it became the #1 New Release in the C# and object-oriented programming category on Amazon.com. The book was translated into Japanese in 2019. This kind of success motivated me to enhance the work further. I was involved in teaching since 2005, which was another motivation to introduce a book like this one. So, it is my privilege to present you with Getting Started with Advanced C#: Upgrade Your Programming Skills. Before I proceed further, I want to thank you for your support to motivate me to write a book like this.
If you ask me about the most fascinating characteristic of this book, Id tell you that similar to Interactive C#, it is also interactive and simple, but this time, you start exploring advanced programming by using some important features in C#. In this book, my goal was not to demonstrate typical and tough programs using all the latest features of C#; instead, like my previous books, the goal is to fuel your creativity and encourage you to implement advanced concepts using core constructs in C#. I always believe that the word core is most important when you learn a programming language. Whatever is the latest feature today, will be outdated tomorrow but the core constructs are evergreen, and in most cases, they function behind the new features unnoticed. This is why although this book is for advanced programmers, in Part 1, I focus on the fundamental features of advanced C#. I show you how to incorporate them in different programming techniques in Part 2.
Youll probably agree that when you travel an unknown path to a destination, it helps to have a caring guide. Learning a new programming language through a book is a journey that was always on my mind. In this book, I not only explain topics in an informative way, I also made the book interactive by using Q&A sessions in each chapter. These sessions assist you in your learning process, and they act as doubt-clearing sessions that make you a feel that you are asking your guide questions (or expressing your doubts), and you are receiving answers from him in a simple one-to-one communication. In most cases, youll get a full demonstration of programs along with the output, followed by important analysis to get maximum benefit. As a result, you can continue reading without interruption.