假设我有一个函数 DoStuff
这是在程序集 A.dll 中定义的。这个函数需要一个 Func<T>
范围。我在 B.dll 中将此函数称为 DoStuff(() => ...)
.
Func<T>
在哪里评价?它似乎在 B.dll 中,但我希望它在 A.dll 中。如果 Func<T>
会发生什么需要外部引用?我是否被迫将它们包含在 B.dll 中?我可以强制它在 A.dll 中执行吗?
最佳答案
lambda 被编译到 B 并在那里执行。
您可以在此处阅读有关其工作原理的更多信息:What are C# lambda's compiled into? A stackframe, an instance of an anonymous type, or?
关于c# - 跨不同程序集的函数参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35179263/