C# delegate
using System;
public class CargoAircraft
{
// Create a delegate type (no return no arguments)
public delegate void CheckQuantity();
// Create an instance of the delegate type
public CheckQuantity ProcessQuantity;
public void ProcessRequirements()
{
// Call the instance delegate
// Will invoke all methods mapped
ProcessQuantity();
}
}
public class CargoCounter
{
public void CountQuantity() { }
}
class Program
{
static void Main(string[] args)
{
CargoAircraft cargo = new CargoAircraft();
CargoCounter cargoCounter = new CargoCounter();
// Map a method to the created delegate
cargo.ProcessQuantity += cargoCounter.CountQuantity;
// Will call instance delegate invoking mapped methods
cargo.ProcessRequirements();
}
}
}
Also in C#:
- dto and automapper
- percentage in c#
- c# getter setter
- how to find the area of a circle
- c# counting lines
- unity instantiate an object
- iphone
- C# datareadeer return null
- c# graphics draw filled rectangle
- unity how to load up a scene
- .net core get image from url
- c# input integer
- get enum by index c#
- unity set sprite transparency
- leantween id
- JavaScriptSerializer() and convert to base64
- unity docs player input
- c# half hour dropdown list
- get hash c#
- c# filter non alphanumeric characters
- loop over enum values
- c# size of enum
- solid principles c#
- c# convert dictionary to anonymous object