Hi Russell,
I am trying to create a property which returns an enum.
The following class does not work, can someone fix it?
I am using VS2003 C++
public __gc class Drive
{
public:
Drive(){}
__property DriveType get_DriveType()
{
return _DriveType;
}
// This is the enum type
__value enum DriveType
{
CDROM, FIXED, REMOVABLE
};
private:
DriveType _DriveType;
};
Thanks
Russell Mangel
Las Vegas, NV
There are two problems with your code:
The first one is that the enum is defined after the property, so you need to
move it above it so that it can be seen at that point by the compiler.
The second is that the property getter will end up generating a property
that has the same name as the type, so that Drive::DriveType will be
ambiguous (it would mean both the type and the property). This can be easily
fixed by renaming either one. Also, you'll want to make the enum definition
public, as well.
--
Tomas Restrepo
to****@mvps.org