Converting array type

  • Thread starter Thread starter Richard L Rosenheim
  • Start date Start date
R

Richard L Rosenheim

I'm converting some routines from C to C#. The code involves having arrays
of bytes which are passed to a function as an array of longs. Well,
technically the C code has a pointer to an array of char which is passed to
the function which treats the pointer as a pointer to an array of longs.

I would appreciate if someone could direct me to an example, article, etc.
that discuss how to convert such code to C#.

TIA,

Richard Rosenheim
 
Richard,
I would appreciate if someone could direct me to an example, article, etc.
that discuss how to convert such code to C#.

The System.Buffer class is handy for doing memory copies between
arrays of simple integer types, I think that would be the best
solution.

In an unsafe context you can do the same as in C, get a pointer to the
array and cast it to some other pointer type. But I'd avoid it if
possible.



Mattias
 
Thanks. Not as efficient as just recasting the type, but it will do the
job.

Richard Rosenheim
 
Back
Top