編譯器錯誤 C3101
具名屬性自變數 'field' 的不合法表達式
初始化具名屬性自變數時,值必須是編譯時間常數。
如需屬性的詳細資訊,請參閱 使用者定義的屬性。
範例
下列範例會產生 C3101。
// C3101.cpp
// compile with: /clr /c
ref class AAttribute : System::Attribute {
public:
int Field;
};
extern int i;
[assembly:A(Field = i)]; // C3101
[assembly:A(Field = 0)]; // OK