Tired of always writing the same code over and over again when writing properties?
Most property definitions are trivial; they just consist of a private field that holds the data, and trivial getter/setter methods over it that have no logic at all.
C++/CLI provides a very nice way to write these kinds of trivial properties in a single declaration, that defines the underlying storage field and allows the compiler to generate the trivial getter and setter. To declare one, simply declare a property without a body, like this:
property String^ Name;
When the compiler sees this, it will generate, under the covers, a private field called "<backing_store>$Name" (yes, that's actually the real name of the field), along with get_Name() and set_Name() methods.
.: tomasr | 2004-10-10 18:57:05 :.