【发布时间】:2012-10-04 15:16:22
【问题描述】:
public interface IFoo
{
void Foo(bool flag = true);
}
public class Test : IFoo
{
void IFoo.Foo(bool flag = true) //here compiler generates a warning
{
}
}
警告说给定的默认值将被忽略,因为它在不允许的上下文中使用。
为什么显式实现的接口不允许使用可选参数?
【问题讨论】:
-
为什么需要覆盖 IFoo 中指定的默认参数?
标签: c# optional-parameters explicit-interface