更新:2007 年 11 月

错误消息

“type”类型的参数不适用于 DefaultValue 属性

对于类型为对象的参数,DefaultParameterValueAttribute 的变量必须是 null、整型、浮点型、boolstringenumchar。该变量不能是 Type 类型或任何数组类型。

示例

下面的示例生成 CS1910。

 复制代码
// CS1910.cs
// compile with: /target:library
using System.Runtime.InteropServices;

public interface MyI
{
   void Test([DefaultParameterValue(typeof(object))] object o);   // CS1910
}