Declares a property for the managed class.
__property function-declarator
The __property keyword introduces the declaration of a property and can appear in a class, interface, or value type. A property can have a Get function (read only), a Set function (write only), or both (read-write).
For more information on properties in a managed object, see Properties of Managed Objects.
In the following example, a property (Size
) is added to the MyClass
declaration. The property is then implicitly set and retrieved using the get_Size
and set_Size
functions:
#using <mscorlib.dll> #using namespace System; __gc class MyClass { __property int get_Size() { ... }; __property void set_Size(int i) { ... }; // compiler generates a pseudo data member called Size }; void main() { MyClass* class1; Int32 curValue; class1->Size = 4; // calls the set_Size function with value==4 curValue= class1->Size; // calls the get_Size function }
Managed Extensions for C++ Keywords | C++ Keywords