Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   .NET (http://www.delphipages.com/forum/forumdisplay.php?f=10)
-   -   Convert routine with pointer math to .NET (http://www.delphipages.com/forum/showthread.php?t=216398)

bilm 06-06-2014 09:13 PM

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

kolbasz 06-07-2014 11:39 AM

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


All times are GMT. The time now is 10:47 PM.

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