Why can a parameter-less anonymous method be assigned to a delegate Action<T> that expects a parameter?
03:51 04 Dec 2025

I'm learning about delegates in C# and came across a pattern that I don't fully understand. I have a generic method that returns an Action, which I expect to be a method that accepts one parameter of type T.

However, it seems I can return an anonymous method with no parameters (delegate {}) without any compiler errors.

Here is a minimal example:

using System;

public class Program
{
    public static Action GetEmptyAction()
    {
        // Why is this line valid?
        // 'delegate {}' has no parameters, but Action expects one.
        return delegate { };
    }
}

My question is:

What C# language rule or feature allows a method with fewer parameters (in this case, zero) to be assigned to a delegate type that expects more parameters?

I've seen the lambda expression _ => {} used for this, which makes it clearer that the parameter is being ignored. Is the delegate {} syntax working based on the same principle of delegate compatibility?

c# generics delegates anonymous-methods