Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / November 2005

Tip: Looking for answers? Try searching our database.

__boxing helena - i mean parity...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Oliphant - 14 Nov 2005 19:11 GMT
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() ;

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.