C# Delegate Instantiation vs. Just Passing the Method Reference [duplicate]

As long as the method group SomeObject.SomeMethod has a method with return type void and taking no parameters there is no difference. This is because ThreadStart is defined as a delegate that returns void and takes no parameters and therefore there is an implicit conversion from the method group SomeObject.SomeMethod to ThreadStart. Thus, both are invoking the overload Thread(ThreadStart) of the Thread constructor .

The relevant section of the language specification is §6.6 (Method group conversions).

I have a simple question: what’s the advantage of instantiating a C# delegate as opposed to just passing the function reference?

So, just a correction of terminology here. With

class MyObject {
    public void SomeMethod() { }
}

MyObject someObject = new MyObject();

the thing denoted by someObject.SomeMethod is a method group. You can just think of it as the set of overloaded methods can that be looked up using the notation someObject.SomeMethod.

Leave a Comment