Compiler Error C3898
'var' : type data members can only be members of managed types
An initonly data member was declared in a native class. An initonly
data member can only be declared in a CLR class.
The following sample generates C3898:
// C3898.cpp
// compile with: /clr
struct Y1 {
initonly
static int data_var = 9; // C3898
};
Possible resolution:
// C3898b.cpp
// compile with: /clr /c
ref struct Y1 {
initonly
static int data_var = 9;
};
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for