Say we have this class:
// Provides deferred behaviour public class Command<TResult> { private Func<object[], TResult> _executeFunction; private object[] _args; public Command(Func<object[], TResult> execution, params object[] arguments) { _executeFunction = execution; _args = arguments; } public TResult Execute() { return _executeFunction(_args); } }
What is the difference between these two anonymous functions?
int a = 1; int b = 4;
I am specifically looking for performance differences.
In addition, we know that if any class contains a link sum2 , then a and b will go beyond the scope in which they were defined, probably will never be collected by GC if the function is still referenced somewhere.
Does the same thing happen with sum ? (Given that the arguments are reference types, not value types, as in this example)
source share