更新:2007 年 11 月
错误消息
DefaultValue 属性的变量类型必须与参数类型匹配
对 DefaultValueAttribute 属性值使用错误的参数时生成此错误。请使用与参数类型匹配的值。
示例
下面的示例生成 CS1908。
// CS1908.cs
// compile with: /target:library
using System.Runtime.InteropServices;
public interface ISomeInterface
{
void Bad([Optional] [DefaultParameterValue("true")] bool b); // CS1908
void Good([Optional] [DefaultParameterValue(true)] bool b); // OK
}