> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C# Multicast Delegate

A multicast delegate in C# is a delegate object that holds references to multiple methods within a single invocation list. When the multicast delegate is invoked, it executes all the methods in its invocation list synchronously, in the exact order they were added. Under the hood, all C# delegates implicitly inherit from the `System.MulticastDelegate` class, which in turn inherits from `System.Delegate`.

You construct a multicast delegate by combining individual delegate instances using the overloaded `+` or `+=` operators. Conversely, you remove methods from the invocation list using the `-` or `-=` operators.

```csharp theme={"dark"}
public delegate void OperationDelegate(string message);

public class MulticastMechanics
{
    public void MethodA(string msg) => Console.WriteLine($"A: {msg}");
    public void MethodB(string msg) => Console.WriteLine($"B: {msg}");
    public void MethodC(string msg) => Console.WriteLine($"C: {msg}");

    public void Execute()
    {
        // 1. Instantiate the initial delegate
        OperationDelegate del = MethodA;

        // 2. Combine delegates to create a multicast delegate
        del += MethodB;
        del += MethodC;

        // 3. Invocation: Executes MethodA, then MethodB, then MethodC
        del("Executing sequence");

        // 4. Remove a delegate from the invocation list
        del -= MethodB;

        // 5. Invocation: Executes MethodA, then MethodC
        del("Executing modified sequence");
    }
}
```

## Architectural Characteristics

**Immutability**
Delegate instances in C# are immutable. When you use the `+=` operator, the compiler translates this into a call to `Delegate.Combine()`. This method does not mutate the existing delegate; instead, it allocates and returns a completely new delegate instance containing the merged invocation lists. The `-=` operator similarly calls `Delegate.Remove()`, returning a new instance with the specified method omitted.

**Return Value Resolution**
While multicast delegates typically define a `void` return type, they are permitted to return values. If a multicast delegate has a non-void return type, the caller receives the return value of the *last* method executed in the invocation list. The return values of all preceding methods are evaluated but discarded.

```csharp theme={"dark"}
public delegate int NumberDelegate();

public class ReturnValueMechanics
{
    public int ReturnOne() => 1;
    public int ReturnTwo() => 2;

    public void Execute()
    {
        NumberDelegate del = ReturnOne;
        del += ReturnTwo;

        // result will be 2. The return value of ReturnOne is lost.
        int result = del(); 
    }
}
```

**Exception Propagation**
Because a multicast delegate processes its invocation list sequentially, an unhandled exception thrown by any method in the list will immediately halt execution. The exception propagates up the call stack to the invoker, and any subsequent methods remaining in the invocation list are not executed.

**Manual Invocation Control**
To bypass default behaviors—such as capturing all return values or preventing a single exception from halting the entire chain—you can manually iterate through the invocation list using the `GetInvocationList()` method. This method returns an array of `System.Delegate` objects representing the individual methods.

```csharp theme={"dark"}
public void ExecuteSafely(OperationDelegate multiDel)
{
    if (multiDel == null) return;

    // Extract the underlying array of individual delegates
    Delegate[] invocationList = multiDel.GetInvocationList();

    foreach (OperationDelegate singleDel in invocationList)
    {
        try
        {
            // Invoke each delegate independently
            singleDel.Invoke("Safe execution");
        }
        catch (Exception ex)
        {
            // Handle exception without breaking the multicast chain
            Console.WriteLine($"Delegate threw an exception: {ex.Message}");
        }
    }
}
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor C# Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
