Is there any functional difference between these to function calls.
Method1:
public static void PrintMe(object obj)
{
Task task = new Task(() =>
{
Console.WriteLine(obj.ToString());
});
task.Start();
}
Method2:
public static void PrintMe(object obj)
{
Task task = new Task((object arg) =>
{
Console.WriteLine(arg.ToString());
}, obj);
task.Start();
}
The first one passes the variable obj to the task. The second one passes the value of obj.
To see the difference assign something else to obj after creating the task.