Scalar number Property
#include "stdafx.h" using namespace System; ref class MyClass{ public: MyClass(){ Cost = 0.0; number = 0; name = "name"; description = "Property"; } property double Cost; property int Number { void set(int value) { if (value < 1) value = 1; else if (value > 10) value = 10; number = value; } int get() { return number; } } property String^ Name { void set(String^ value) { name = value; } } property String ^Description { String^ get() { return String::Concat(name, " ", description); } } private: String ^name; String ^description; int number; }; void main() { MyClass sp; sp.Name = "new name"; Console::WriteLine(sp.Description); sp.Cost = 123.45; Console::WriteLine(sp.Cost); sp.Number = 20; Console::WriteLine(sp.Number); sp.Number = -5; Console::WriteLine(sp.Number); sp.Number = 6; Console::WriteLine(sp.Number); }