我在程序集中有以下方法:
public string dostuff(string foo, object bar = null) { /* ... */ }
Run Code Online (Sandbox Code Playgroud)
我将它用作回调函数,因此对它的引用会传递给另一个程序集:
Func<string, object, string> dostuff
Run Code Online (Sandbox Code Playgroud)
现在以原始形式,我可以调用它而不指定第二个参数,默认为null.但是当我在第二个程序集中使用它作为回调时,我必须指定第二个参数.
什么语法允许我忽略第二个参数?
为什么这段代码不能编译?
delegate int xxx(bool x = true);
xxx test = f;
int f()
{
return 4;
}
Run Code Online (Sandbox Code Playgroud)