編譯器錯誤 C3898
'var' :類型數據成員只能是Managed 類型的成員
原生類別中宣告了 Initonly 數據成員。 initonly
數據成員只能在 CLR 類別中宣告。
下列範例會產生 C3898:
// C3898.cpp
// compile with: /clr
struct Y1 {
initonly
static int data_var = 9; // C3898
};
可能的解決方式:
// C3898b.cpp
// compile with: /clr /c
ref struct Y1 {
initonly
static int data_var = 9;
};