Re: *int Vs IntPtr
- From: "Michael C" <nospam@xxxxxxxxxx>
- Date: Thu, 16 Nov 2006 11:42:45 +1100
"Tom Spink" <tspink@xxxxxxxxx> wrote in message
news:%23FVOGbNCHHA.3228@xxxxxxxxxxxxxxxxxxxxxxx
Surely IntPtr would be slower as you need to copy data back and forward
to
arrays in order to use it.
Can you explain what you mean by this?
Sure, if you have an intptr to some memory and you want to, say, increment
every byte by 1 you would need to do this:
IntPtr ptr = GetPointerFromSomewhere();
byte[] data = new byte[32];
marshal.Copy(ptr, data, 32); //can't remember exact syntax
for(int i = 0; i < 32; i++) data[i]++;
marshal.Copy(data, ptr, 32);
But if you have a byte* you don't need the 2 copies:
byte* ptr = GetPointerFromSomewhere();
for(int i = 0; i < 32; i++) ptr[i]++;
Of course this is irrelevant if you are just keeping a pointer to pass to
API calls etc.
Michael
.
- References:
- Re: *int Vs IntPtr
- From: Michael C
- Re: *int Vs IntPtr
- From: Tom Spink
- Re: *int Vs IntPtr
- Prev by Date: Re: Parsing Multipart formdata
- Next by Date: Re: Parsing Multipart formdata
- Previous by thread: Re: *int Vs IntPtr
- Next by thread: Re: Tab Controls???
- Index(es):
Relevant Pages
|
Loading