[Mono-list] Marshalling byte[]

Dmitry Kostenko bis0n@mail.ru
Wed, 27 Oct 2004 17:16:08 +0300


Hello, Neale.

You could use:

extern static void f([MarshalAs(UnmanagedType.LPArray] byte[] p, int size);

C function:
void f(char* p, int size) {}

C# call:

byte[] val = new byte[1024];

f(val, val.Length);

Neale.Ferguson@SoftwareAG-USA.com wrote:
> I have a variable:
> byte[] var;
> 
> That I wish to pass to a C program. Normally, I could use something like:
> [MarshalAs(UnmanagedType.ByValArray, SizeConst=8)]
> byte[] var;
> 
> But in my case I do not know the size of the variable until runtime. How do I get something like this marshalled at runtime?
> 
> Neale
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
> 
> 

-- 
Dmitry Kostenko
.NET Developer