Export (0) Print
Expand All

Properties Sample: Demonstrates Standard and Indexed Properties for a Managed Class

Visual Studio .NET 2003

The Properties sample illustrates how to declare and implement standard and indexed properties for a managed class (X) using the __property keyword. The managed class exposes two properties:

  • Size property

    A simple read-write custom property that allows the user to get and set the value of an integer.

  • Value property

    A read-write indexed property that allows the user to get and set an integer value at the specified index.

The sample first creates and initializes the X class. The Size property is set (using the _setSize method) to 4, and the 6th element of the Value property is set to 2 (using the _setValue method). The new values are then retrieved using their respective Get methods and verified.

Building and Running the Sample

To build and run Properties using Visual Studio

  1. In the Visual Studio IDE, load the solution file properties.sln.
  2. In Solution Explorer, right-click the properties solution.
  3. On the shortcut menu, click Build.
  4. On the Debug menu, click Start.

See Also

Managed Extensions for C++ Samples

Show:
© 2014 Microsoft