Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

How to: Use Simple Properties

For simple properties, those that merely assign and retrieve a private data member, you do not explicitly define the get and set accessor functions. The compiler will automatically provide accessor functions, given just the data type of the property The code below demonstrates a simple property.

// SimpleProperties.cpp
// compile with: /clr
using namespace System;

ref class C {
public:
   property int Size;
};

int main() {
   C^ c = gcnew C;
   c->Size = 111;
   Console::WriteLine("c->Size = {0}", c->Size);
}
c->Size = 111
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.