To remove delegates from a multicast delegate, use the Remove method, the minus operator (-), or the -= assignment operator.
using System;
public delegate void DelegateClass();
public class Starter {
public static void Main(){
DelegateClass del=MethodA;
del+=MethodB;
del+=MethodC;
del=del-MethodB;
del();
}
public static void MethodA() {
Console.WriteLine("MethodA...");
}
public static void MethodB() {
Console.WriteLine("MethodB...");
}
public static void MethodC() {
Console.WriteLine("MethodC...");
}
}
Related examples in the same category