public ref class Class1
{
private:
static array<String^>^ _myProperty;
public:
static property array<String^>^ MyProperty
{
array<String^>^ get()
{
return _myProperty;
}
void set(array<String^>^ value)
{
_myProperty = value;
}
}
};
The commented code is another valid way to do it.
string
is not a keyword in C++/CLI as in C#, so you have to use the class name
String
. You may also consider not having a "public" set accessor for the property since by doing so you're allowing other entities to replace the whole array reference while you probably want to just give them access to the array items (assuming the set method to be setting the backing field). More information regarding properties in C++/CLI is
here[
^].