.NET : .NET News
Updated: 7/1/2002; 9:30:03 PM.

 

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Saturday, May 04, 2002


I'd mentioned that MC++ provides mode control over boxing and unboxing than C#. Here's an example of directly modifying boxed value types on the heap, without unboxing & reboxing them or resorting to adjustor interfaces:

<a href="//">// HeapMod.cpp: cl.exe /clr HeapMod.cpp 
#using  using namespace System; 
__value struct Universe { int Answer; }; 
void main() { 
Universe u; 
Object* po = __box(u); 
Universe* pu = __try_cast(po); 
pu->Answer = 42; 
Universe* pu2 = __try_cast(po); Console::WriteLine(pu2->Answer); }

[Peter Drayton's Radio Weblog]

Thans Peter for doing my work for me again-). I should be doing this as the author of a Managed C++ book, but there is so little time (especially when my wife wants to get my off the computer so much that she hides my keyboard! -))

 



8:54:33 AM    


© Copyright 2002 Sam Gentile.



Click here to visit the Radio UserLand website.

 


May 2002
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Apr   Jun

Click on the coffee mug to add Sam Gentile's Instant Outline to your Radio UserLand buddy list.