'var' :必須初始化靜態數據成員
未正確初始化標示 為 initonly 的變數。
下列範例會產生 C3883:
// C3883.cpp
// compile with: /clr
ref struct Y1 {
initonly
static int staticConst1; // C3883
};
下列範例示範可能的解決方式:
// C3883b.cpp
// compile with: /clr /c
ref struct Y1 {
initonly
static int staticConst2 = 0;
};
下列範例示範如何在靜態建構函式中初始化:
// C3883c.cpp
// compile with: /clr /LD
ref struct Y1 {
initonly
static int staticConst1;
static Y1() {
staticConst1 = 0;
}
};