Re: Boxing and Unboxing ??
- From: Barry Kelly <barry.j.kelly@xxxxxxxxx>
- Date: Sat, 13 Jan 2007 22:13:51 +0000
Peter Olcott wrote:
Well that's not too bad then. It would seem that good design might be able to
completely eliminate the boxing and unboxing overhead penalty.
Yup. Nobody I know with experience worries much about this.
Is it possible to pass data around as unboxed data?
Yes - declare your types rather than using 'object'.
Can I pass the address of a struct, so that a
class member can update this struct without boxing and unboxing?
You can, but in a strictly downwards (call stack) fashion, via the 'ref'
modifier on arguments. You can't safely store the address.
With unsafe code, you can use the '&' operator to get the address, and
basically write C code to manipulate the data. But that's unsafe code:
it's not verifiable, it won't work if the executable is run from a
network location, and almost certainly won't work if you're (e.g.)
writing an ASP.NET application for hosting on a server somewhere -
unless you control the server & permissions completely.
What is the best way to get one class to update the struct data of another
class?
By calling methods on the other class.
-- Barry
--
http://barrkel.blogspot.com/
.
- Follow-Ups:
- Re: Boxing and Unboxing ??
- From: Peter Olcott
- Re: Boxing and Unboxing ??
- References:
- Boxing and Unboxing ??
- From: Peter Olcott
- Re: Boxing and Unboxing ??
- From: Jesse McGrew
- Re: Boxing and Unboxing ??
- From: Peter Olcott
- Re: Boxing and Unboxing ??
- From: Jesse McGrew
- Re: Boxing and Unboxing ??
- From: Peter Olcott
- Re: Boxing and Unboxing ??
- From: Barry Kelly
- Re: Boxing and Unboxing ??
- From: Peter Olcott
- Re: Boxing and Unboxing ??
- From: Bruce Wood
- Re: Boxing and Unboxing ??
- From: Peter Olcott
- Boxing and Unboxing ??
- Prev by Date: Re: Is it possible to hide methods to certain classes?
- Next by Date: Re: Boxing and Unboxing ??
- Previous by thread: Re: Boxing and Unboxing ??
- Next by thread: Re: Boxing and Unboxing ??
- Index(es):