P
Philippe Bertrand
Using C#, I want to send a byte array to an unmanaged function with the
minimum amount of copies. The array is input only and won't be modified
(its copied on the unmanaged side).
I'm currently using fixed byte *. My question is: Should I be using In
byte[] parameter instead? Ref parameter?
fixed( byte *b = byte_array ) {
MyUnmangedFunc2( b, byte_array.Length );
}
[DllImport("foo.dll")] private static extern unsafe void MyUnmanagedFunc2(
byte *val, int count );
--OR--
MyUnmanagedFunc2( byte_array, byte_array.Length );
[DllImport("foo.dll")] private static extern unsafe void MyUnmanagedFunc2(
In byte[] val, int count );
I need a solution for both the compact framework and desktop framework.
(Don't have to be the same but closer the better)
Thanks,
Philippe
minimum amount of copies. The array is input only and won't be modified
(its copied on the unmanaged side).
I'm currently using fixed byte *. My question is: Should I be using In
byte[] parameter instead? Ref parameter?
fixed( byte *b = byte_array ) {
MyUnmangedFunc2( b, byte_array.Length );
}
[DllImport("foo.dll")] private static extern unsafe void MyUnmanagedFunc2(
byte *val, int count );
--OR--
MyUnmanagedFunc2( byte_array, byte_array.Length );
[DllImport("foo.dll")] private static extern unsafe void MyUnmanagedFunc2(
In byte[] val, int count );
I need a solution for both the compact framework and desktop framework.
(Don't have to be the same but closer the better)
Thanks,
Philippe