Events and Delegates

Introduction

This article will deal with Event and delegates in C#. C# Open a new door by including the feature of Event Driven programming such as Events and Delegates. This article is part of the series that helps in understanding Events and Delegates.

Events are the means by which Windows Application receive notification. In a Windows application a lot of Events are occurring at a particular instant for e.g. Mouse Move, Mouse out, Mouse Click etc. Delegates are pointer to the function and are type-safe.

Another very interesting feature in C# is delegates. Delegates are best complemented as new type of Object in C#. They are also represented as pointer to functions. Technically delegate is a reference type used to encapsulate a method with a specific signature and return type. Since in this article delegate discussion is event centric. If we consider a real world scenario then delegates can be understood as any delegate representing a country a group of people representing a company etc. This same definition can be mapped to C# as delegate act as an intermediary between event source and destination.  The DotNetFrameWork has a Name Space System.Delagate. We have two flavors of delegate in C#.

  • Single Delegate
  • Multi-cast Delegate

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Nine people can't make a baby in a month.” - Fred Brooks