Visual C++ .NET/Class/initonly
initonly static field
<source lang="csharp">
- include "stdafx.h"
using namespace System; ref class MyClass {
public: static initonly String^ name = "a"; // OK
};
</source>
initonly string
<source lang="csharp">
- include "stdafx.h"
using namespace System; ref class MyClass {
initonly String^ name; public: MyClass(String^ first, String^ last) { name = first + last; } void Print() { Console::WriteLine(name); // OK }
}; int main() {
MyClass^ r = gcnew MyClass("a", "a"); r->Print();
}
</source>