共用方式為


編譯器錯誤 C3114

'argument': 不是有效的具名屬性自變數

為了讓屬性類別資料成員成為有效的具名自變數,它不得標示 static為、 constliteral。 如果屬性,屬性不得為 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 {};