Book Image

Programming in C#: Exam 70-483 (MCSD) Guide

By : Simaranjit Singh Bhalla, SrinivasMadhav Gorthi
Book Image

Programming in C#: Exam 70-483 (MCSD) Guide

By: Simaranjit Singh Bhalla, SrinivasMadhav Gorthi

Overview of this book

Programming in C# is a certification from Microsoft that measures the ability of developers to use the power of C# in decision making and creating business logic. This book is a certification guide that equips you with the skills that you need to crack this exam and promote your problem-solving acumen with C#. The book has been designed as preparation material for the Microsoft specialization exam in C#. It contains examples spanning the main focus areas of the certification exam, such as debugging and securing applications, and managing an application's code base, among others. This book will be full of scenarios that demand decision-making skills and require a thorough knowledge of C# concepts. You will learn how to develop business logic for your application types in C#. This book is exam-oriented, considering all the patterns for Microsoft certifications and practical solutions to challenges from Microsoft-certified authors. By the time you've finished this book, you will have had sufficient practice solving real-world application development problems with C# and will be able to carry your newly-learned skills to crack the Microsoft certification exam to level up your career.
Table of Contents (22 chapters)
17
Mock Test 1
18
Mock Test 2
19
Mock Test 3

What this book covers

Chapter 1, Learning the Basics of C#, focuses on the basics of the C# language. In this chapter, you will learn about the underlying .NET Framework architecture and how all the components, such as the garbage collector, common language runtime, base libraries, and so on, interact with each other. We will analyze the similarities between C# and other programming languages such as C++ and C. We will also look at features that make C# different than C++ and C. Finally, using a very basic Hello World program, you will learn about the different components of a C# program, such as classes, namespaces, assemblies, and so on.

Chapter 2, Understanding Classes, Structures, and Interfaces, expands on the first chapter and covers some more basics of a C# application. In this chapter, you will learn about the different access modifiers available in a C# program, and also how they can be used to achieve code structure and reduced complexity. We will also look at the different primitive data types available in C#. While looking at the class and struct variables, we will see the difference between a reference type variable and a data type variable. We will then look at inheritance, which is an important aspect of C# programming. We will cover how inheritance is implemented in C# and how it differs from the implementation of an interface.

Chapter 3, Understanding Object-Oriented Programming, focuses on the four pillars of Object-Oriented Programming (OOP). Using examples, you will learn how each of those pillars – encapsulation, polymorphism, abstraction, and inheritance—is implemented. While looking at inheritance, we will expand on the learning of Chapter 2, Understanding Classes, Structures, and Interfaces, and look at some other critical aspects, such as method overriding, virtual methods, and sealed and abstract classes. While looking at polymorphism, we will learn how we can implement both compile/static and runtime polymorphism in C# programs.

Chapter 4, Implementing Program Flow, focuses on how a developer can manage program flow in C#. In other words, this chapter helps you to understand how to control the program and make decisions using the statements available in C#. We will cover various Boolean expressions such as if/else and switch, which control the flow of code based upon conditions. This chapter also provides an overview of various operators, such as the conditional operator and the equality operator (<, >, and ==), which govern the flow of code. Apart from operators and decision-making statements, this chapter helps you gain an understanding of iterating through collections (for loop, while loop, and so on) and explicit jump statements.

Chapter 5, Creating and Implementing Events and Callbacks, focuses on events and callbacks in C#, which are important and give more control over the program. You'll learn about the publish/subscribe model using events and callbacks, and focus on delegates. Then, we will move on to different ways of initiating delegates and lambda expressions. We will also spend some time on a new operator called the lambda operator, which is used in Lambda expressions.

Chapter 6, Managing and Implementing Multithreading, focuses on handling responsiveness in long-running programs and how we can keep the user notified about their progress. We'll also look at how we can use the multi-core processing power that comes with every computer effectively. We will spend time looking at threads, thread properties, and how to use tasks and perform multithreaded operations.

Chapter 7, Implementing Exception Handling, focuses on understanding how to structure your program in a way that helps it to run in all scenarios; how we can handle unhandled exceptions; how to use the try, catch, and finally keywords and clean up resources once execution is completed. After reading this chapter, you will understand exceptions and how to use them in your program. You'll also be able to create custom exceptions.

Chapter 8, Creating and Using Types in C#, focuses on the different types of variables available in C#. In Chapter 2, Understanding Classes, Structures, and Interfaces, we introduced users to the reference and data type variables available in C#. In this chapter, we will expand on that knowledge and learn how both variable types are maintained in memory. We will look at the managed heap memory structure, which is used for saving reference type variables. We will also look at the use of variable types pointer types in C#. Using pointers, we can implement memory-related operations that are otherwise considered unsafe in C#. We will also look at some important features in C#, such as properties, named arguments, and optional arguments, which are available in C# programming. We will look at how we can convert value-type variables to objects using boxing and similarly use unboxing to convert the object back to a value-type variable. We will then look at the different operations that are possible on a string representation in C#. We will also look at how we can use stringbuilder to optimize the performance of a C# program.

Chapter 9, Managing the Object Life Cycle, focuses on how the garbage collector manages the allocation and release of memory in .NET Framework. In this chapter, you will learn the difference between managed and unmanaged code in C#. We will look at mark-compact algorithms, used by garbage collectors for the allocation and release of memory. We will look at the possible ways we can manage the memory allocated to unmanaged code. We will also look at how we can implement finalization in a C# application and the performance implications of doing so. We will introduce the IDisposable interface and understand its differences from a finalize block. We will also look at code examples, in which we will combine both the IDisposable interface and a finalize block to achieve the best possible memory management for a C# application. Finally, we will look at the use of the using block in a C# application.

Chapter 10, Find, Execute, and Create Types at Runtime Using Reflection, focuses on understanding how .NET Framework allows us to read/create metadata and how we can use reflection to read metadata and process it during runtime. We will focus on using attributes, creating custom attributes, and how we can retrieve attribute information at runtime. We'll also cover how we can use reflection to create types, access properties, and invoke methods.

Chapter 11, Validating Application Input, focuses on validating input from the different kinds of users who'll access your application and how we can avoid the application crashing based on user input. The purpose of this chapter is to understand the importance of validating input data in your application, the different validation techniques available in .NET Framework, and ways to validate JSON data and XML data.

Chapter 12, Performing Symmetric and Asymmetric Encryption, focuses on how to keep information secure, what measures we can take while transmitting information over the internet, and understanding cryptography to encrypt and decrypt plain text. After reading this chapter, you will understand how to encrypt and decrypt text and be familiar with the different algorithms available in .NET Framework to perform such exercises.

Chapter 13, Managing Assemblies and Debugging Applications, focuses on how to manage .NET assemblies, debugging applications, and how to use tracing. This chapter covers validation techniques we have already learned and exception handling for those scenarios, as well as monitoring code blocks. We'll also look at Visual Studio features or tools for debugging an application. After that, we'll look at the versioning of assemblies and how we can have the same assembly side by side, as well as how we can distribute those assemblies without impacting others.

Chapter 14, Performing I/O Operations, focuses on how I/O operations are performed in a C# application. In this chapter, we will look at the different operations possible in C# to access data in I/O files as well as operations coming from external web services. Using code examples, you will see how we can use the System.IO helper class to read/write data from a file. We will also look at the helper classes of File and FileInfo provided in C# for performing I/O operations. We will then look at the WebRequest and WebResponse helper classes, which help us to interact with data coming from external services/applications. Finally, we will look at how we can execute these operations asynchronously in an application.

Chapter 15, Using LINQ Queries, focuses on how LINQ queries are implemented in C#. In this chapter, you will be introduced to the basics of a LINQ query, gaining an understanding of the different components and how they are constructed in .NET Framework. We will then look at the features in C# that help with the implementation of LINQ queries. Some of those features are necessary while some of them help us to get the best outcomes from LINQ queries. Using code examples, you will come to understand the implementation of implicitly typed variables, object initialization syntax, Lambda expressions, extension methods, and anonymous types. We will then look at the different operations available in LINQ queries. Using code examples, you will learn about the different scenarios in which you can use each of these operators. Finally, we will look at how you can use LINQ queries to perform operations on an XML file.

Chapter 16, Serialization, Deserialization, and Collections, focuses on different serialization and deserialization approaches, such as XML serialization, JSON serialization, and binary serialization, available in .NET Framework. We will also look at how we can define data contracts in web services so that data can be exchanged between different applications. We will then look at different collection objects, such as arrays, lists, dictionary, queues, and stacks, available in C# and understand how they can be used to store and consume data.