编译器错误 C3114

'argument':不是有效的命名特性参数

为了使属性类数据成员成为有效的命名参数,不得将它标记为 staticconstliteral。 如果为属性,该属性不得为 static,且必须具有 get 和 set 访问器。

有关详细信息,请参阅属性用户定义的特性

示例

下面的示例生成 C3114。

// C3114.cpp
// compile with: /clr /c
public ref class A : System::Attribute {
public:
   static property int StaticProp {
      int get();
   }

   property int Prop2 {
      int get();
      void set(int i);
   }
};

[A(StaticProp=123)]   // C3114
public ref class R {};

[A(Prop2=123)]   // OK
public ref class S {};