Book Image

Learn C# in 7 days

By : Gaurav Aroraa
1 (1)
Book Image

Learn C# in 7 days

1 (1)
By: Gaurav Aroraa

Overview of this book

This book takes a unique approach to teach C# to absolute beginners. You’ll learn the basics of the language in seven days. It takes a practical approach to explain the important concepts that build the foundation of the C# programming language. The book begins by teaching you the basic fundamentals using real-world practical examples and gets you acquainted with C# programming. We cover some important features and nuances of the language in a hands-on way, helping you grasp the concepts in a fluid manner. Later, you’ll explore the concepts of Object-Oriented Programming (OOP) through a real-world example. Then we dive into advanced-level concepts such as generics and collections, and you’ll get acquainted with objects and LINQ. Towards the end, you’ll build an application that covers all the concepts explained in the book. By the end of this book, you will have next-level skills and a good knowledge of the fundamentals of C#.
Table of Contents (15 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Overview of delegates and events


In this section, we will discuss the basics of delegates and events. Both delegates and events are the most advanced features of the C# language. We will understand these in coming sections in detail.

Delegates

In C#, delegates are a similar concept to pointers to functions, as in C and C++. A delegate is nothing but a variable of a reference type, which holds a reference of a method, and this method is triggered.

Note

We can achieve late binding using delegates. In Chapter 7, Understanding Object Oriented Programing with C#, we will discuss late binding in detail.

System.Delegate is a class from which all delegates are derived. We use delegates to implement events.

Declaring a delegate type

Declaring a delegate type is similar to the method signature class. We just need to declare a type public delegate string: PrintFizzBuzz(int number);. In the preceding code, we declared a delegate type. This declaration is similar to an abstract method with the difference that...