Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > .NET

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 06-06-2014, 09:13 PM
bilm bilm is offline
Junior Member
 
Join Date: Nov 2012
Posts: 3
Default Convert routine with pointer math to .NET

I do a lot of byte swapping and use an old popular routine that saves using separate multiple routines. It can swap bytes in any size of unsigned integer or byte array.

I need to convert it to .NET so no pointer math. I also need to keep the same parameters 'source', 'destination' and 'byte count'.

procedure SwapBytes(const Source; var Dest; Count: LongInt);
var pSrc, pDst : PChar;
i : LongInt;
begin
pSrc := @Source;
pDst := PChar(@Dest) + Count;
for i := 0 to Count-1 do
begin
Dec(pDst);
pDst^ := pSrc^;
Inc(pSrc);
end;
end;

I can't figure out how to do it.

Bilm
Reply With Quote
  #2  
Old 06-07-2014, 11:39 AM
kolbasz kolbasz is offline
Senior Member
 
Join Date: Nov 2013
Posts: 841
Default

http://www.c-sharpcorner.com/UploadF...sInCSharp.aspx
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:22 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.