TLDR; Why does this work.
Queue<Action> queue = new Queue<Action>();
queue.Enqueue(() => Load("Scene01"));
But not this.
Queue<Action> queue = new Queue<Action>();
queue.Enqueue(Load("Scene01"));
I was trying to create a simple load system that allow scheduling multiple loads at the same time. Found it would be simple storing request as action which then gets added to a queue that some function makes its way through.
The loading function I use is overloaded, and thus the actions created will differ from one another. At first I though I'd be require to create some kind of generic system that could take different actions, but then I found this.
Storing a list of methods in C#
Question Why is it that you can pass a function that doesn't match the action using a lambda expression?
Queue<Action> queue = new Queue<Action>();
private void Load() { }
private void Load(string n) { }
private void QueueLoad()
{
// This match action signature.
queue.Enqueue(Load);
// This does not match, nor work.
queue.Enqueue(Load("Scene01"));
// Adding lambda expression and it works. Why?
queue.Enqueue(() => Load("Scene01"));
}