Multicasting
This lesson spans over multicast delegates, which is an integral part of delegates in C#.
We'll cover the following...
Example
Fun part in using delegates is that you can point to multiple functions using them, at the same time. This means that by calling a single delegate, you can actually invoke as many functions as you want.
Let’s look at the example:
Press + to interact
using System;delegate void Procedure();class DelegateDemo{public static void Method1(){Console.WriteLine("Method 1");}public static void Method2(){Console.WriteLine("Method 2");}public void Method3(){Console.WriteLine("Method 3");}static void Main(){Procedure someProcs = null;someProcs += new Procedure(DelegateDemo.Method1);someProcs += new Procedure(Method2); // Example with omitted class nameDelegateDemo demo = new DelegateDemo();someProcs += new Procedure(demo.Method3);someProcs();}}
...
Access this course and 1400+ top-rated courses and projects.