samedi 2 juillet 2016

How does compiler infer the delegate type from LAMBDA expression?

SAMPLE CODE

int id = 123;

ThreadPool.QueueUserWorkItem(state => ThreadEntryPoint((int)state), id);

public void ThreadEntryPoint(int uniqueId)
{
   Console.WriteLine("uniqueId=" + uniqueId);
}

QUESTION

From the provided LAMBDA expression, how does the compiler know that it needs to create an instance of QueueUserWorkItem(WaitCallback, Object)?

More specifically: I understand that it is inferring the delegate type. What I don't understand is what decision tree (from a high level) is it going through to select the correct delegate type to instantiate?

REFERENCES





Aucun commentaire:

Enregistrer un commentaire