Skip to main content
Top

2018 | Book

Interactive C#

Fundamentals, Core Concepts and Patterns

insite
SEARCH

About this book

Discover object-oriented programming with core concepts of C# in this unique tutorial. The book consists of four major sections which cover 15 core topics - nine of them are dedicated to object-oriented programming, five of them are dedicated to advanced concepts of C#, and one of them is dedicated to design patterns, with coverage of three Gang of Four design patterns with C# implementations. Finally, Interactive C# contains an FAQ section to cover all of these topics.

This book uniquely presents a two-way discussion between a teacher and students. So, with this book you will have the feel of learning C# in a classroom environment or with your private tutor. Your teacher will discuss the problems/topics and ask you questions; at the same time, counter questions are provided to clarify points where necessary.

What You Will Learn

Become proficient in object-oriented programming

Remake yourself as a great C# programmer

Test your skills in C# fundamentals

Use Visual Studio to write, compile and execute your codeWho This Book Is For

Programmers who want to understand the concepts and implementation of object-oriented programming in C#.

Table of Contents

Frontmatter

Enter into the World of OOP

Frontmatter
Chapter 1. Object-Oriented Programming Concepts
Abstract
Welcome to object-oriented programming (OOP). You may already be familiar with the proverb “Necessity is the mother of invention.” The same concept applies here. If we have a basic idea about why we introduced this type of programming, or how these concepts will make real-world programming easy, our learning paths will be enjoyable and we will be able to extend our learnings in various directions. Therefore, I’ll try to address some common questions then I’ll provide an overview of object-oriented programming.
Vaskaran Sarcar
Chapter 2. The Building Blocks: Class and Objects
Abstract
A class is a blueprint or a template. It can describe the behaviors of its objects. It is the foundation for how the object is built or instantiated.
Vaskaran Sarcar
Chapter 3. The Concept of Inheritance
Abstract
Teacher starts the discussion: The main objective of inheritance is to promote reusability and eliminate redundancy (of code). The basic idea is that a child class can obtain the features/characteristics of its parent class. In programming terms, we say that a child class is derived from its parent class. Therefore, the parent class is placed at a higher level in the class hierarchy.
Vaskaran Sarcar
Chapter 4. Get Familiar with Polymorphism
Abstract
In compile-time polymorphism, the compiler can bind the appropriate methods to the respective objects during the compile time because it has all the necessary information (e.g., method arguments). So, it can decide which method to call much earlier once the program is compiled.
Vaskaran Sarcar
Chapter 5. Interfaces: An Art in OOP
Abstract
Teacher starts the discussion: An interface is a special type in C#. An interface contains only method signatures to define some specifications. The subtypes need to follow those specifications. When you use an interface, you may find many similarities with an abstract class.
Vaskaran Sarcar
Chapter 6. Encapsulation with Properties and Indexers
Abstract
Teacher starts the discussion: We already know that encapsulation is one of the key characteristics in object-oriented programming. In C#, properties are very important because they help encapsulate an object state. A property is a member that provides a flexible mechanism to read, write, or compute the value of a private field. Initially, properties may appear similar to fields, but actually they have either get or set or both blocks attached with them. These special blocks/methods are called accessors. In simple terms, get blocks are used for reading purposes and set blocks are used for assigning purposes.
Vaskaran Sarcar
Chapter 7. Understanding Class Variables
Abstract
Teacher starts the discussion: Sometimes we do not want to operate through instances of a type. Instead, we prefer to work on the type itself. The concept of class variables or class methods comes to mind in these scenarios. They are commonly known as static variables or static methods. In C#, the class itself can be static. In general, when we tag the keyword static to a class, it is a static class; when it is tagged with a method, it is called a static method; and when we associate it with a variable, it is known as a static variable.
Vaskaran Sarcar
Chapter 8. Analysis of Some Key Comparisons in C#
Abstract
In this chapter, we will focus on implicit and explicit conversions. Let’s go through them now.
Vaskaran Sarcar
Chapter 9. A Quick Recap of OOP Principles in C#
Abstract
Teacher starts the discussion: Welcome to the final part of the object-oriented programming in C#.Let’s review the core principles that we already covered in this book.
Vaskaran Sarcar

Get Familiar with Some Advanced Concepts

Frontmatter
Chapter 10. Delegates and Events
Abstract
Teacher starts the discussion: Delegates are one of the most important topics in C# programming, and they have made C# very powerful. Delegates are reference types derived from System.Delegate. They are similar to object references but the key distinction is that they point to methods. We can achieve type safety with the use of delegates. For this reason, sometimes we refer to them as type-safe function pointers.
Vaskaran Sarcar
Chapter 11. Flexibilities with Anonymous Functions
Abstract
Teacher starts the discussion: Let’s go back to our delegate program (DelegateEx1). I have added few lines of code to that program to generate the same output. To help you to understand the differences among invocations, I have kept the old stuffs as it is.
Vaskaran Sarcar
Chapter 12. Generics
Abstract
Later, we will do a comparative analysis and then discover the advantages of generic programming. Consider the following program and the output.
Vaskaran Sarcar
Chapter 13. Exception Handling
Abstract
Teacher starts the discussion: In general, when we write code for an application, we have the expectation that it will always execute without any problem. But sometimes, we encounter sudden surprises when we execute those programs. These surprises may occur in various ways and through some careless mistakes (e.g., trying to implement the wrong logic, or ignoring some loopholes in the code paths of the program, etc.) However, it is also true that many of the failures are beyond the control of a programmer. We often call these unwanted situations exceptions. Handling these exceptions are essential when we write an application.
Vaskaran Sarcar
Chapter 14. Memory Cleanup
Abstract
However, there is a catch. Some objects require special teardown codes to release resources. A very common example is when we open one or more files and then perform some operation (e.g., reading, writing, etc.) but forget to close the file(s). A similar kind of attention may be needed in other situations, such as when we deal with unmanaged objects, locking mechanisms, or operating system handles in our programs, and so forth. Programmers explicitly need to release those kinds of resources.
Vaskaran Sarcar

Become a Hero in the Real World

Frontmatter
Chapter 15. An Introduction to Design Patterns
Abstract
There were no standards to instruct them on how to design and proceed. The issue became significant when a new member (experienced or inexperienced does not matter) joined the team, and he/she was assigned to do something from scratch or to modify something in the existing architecture.
Vaskaran Sarcar
Chapter 16. Winning Notes and the Road Ahead
Abstract
Congratulations. You have reached the end of the journey. All of us can start a journey but only few among us can complete it with care. So, you are among the minority who have that extraordinary capability to cover the distance successfully. I believe that you have enjoyed your learning experience. The same experience can help you learn any new topic in this category. Earlier, I said that if you repeatedly think about the questions and answers discussed in the book, you will have more clarity about them, you will feel confident about them, and you will remake yourself in the programming world.
Vaskaran Sarcar
Backmatter
Metadata
Title
Interactive C#
Author
Vaskaran Sarcar
Copyright Year
2018
Publisher
Apress
Electronic ISBN
978-1-4842-3339-9
Print ISBN
978-1-4842-3338-2
DOI
https://doi.org/10.1007/978-1-4842-3339-9

Premium Partner