OK, I'm mixing old style with new style, so sue me... : )
Will under old syntax, I'm able to create a SerialPort instance. But, when I
try to convert the Parity proerty to a String*, I get the following compiler
error:
error C3610: value type must be 'boxed'
Here is the code:
SerialPort* port = new SerialPort() ;
Parity parity = port->Parity() ;
String* port_str = parity.ToString() ; // 'boxing' error
Never 'boxed' before, don't know how. How do I convert Parity to a String*
equivalent (i.e., how do I change the above code to properly box 'parity' so
ToString() can be evaluated)? If I write the equivalent code in /clr format
no boxing is necessary ('natch), but I need to do this (for now) in old
syntax.
Thanks in advance for responses! : )
[==P==]
PS - I'm writnig a home project using the new /clr syntax. If you START
using this syntax its awesome! If you have to convert old syntax managed C++
to it, its an intimidating task to say the least... : )
Tomas Restrepo (MVP) - 14 Nov 2005 23:09 GMT
Peter,
> OK, I'm mixing old style with new style, so sue me... : )
>
[quoted text clipped - 15 lines]
> format no boxing is necessary ('natch), but I need to do this (for now) in
> old syntax.
You need to box the value here because in old style MC++, you couldn't
directly access inherited methods in a value (i.e. an instance of a value
type) unless the type overrode those methods (that's why you can call
ToString() directly on some value types and not on others).
In this case, you need to box it, which can be done using the __box()
operator:
String* port_str = __box(parity)->ToString() ;

Signature
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/
Peter Oliphant - 14 Nov 2005 23:20 GMT
Yup, that did the trick! Thanks! : )
[==P==]
> Peter,
>
[quoted text clipped - 27 lines]
>
> String* port_str = __box(parity)->ToString() ;