Convert between python array and .NET Array

Posted by dungema on Stack Overflow See other posts from Stack Overflow or by dungema
Published on 2010-06-11T06:34:10Z Indexed on 2010/06/11 6:43 UTC
Read the original article Hit count: 258

Filed under:
|
|
|
|

I have a python method that returns a Python byte array.array('c').

Now, I want to copy this array using System.Runtime.InteropServices.Marshal.Copy. This method however expects a .NET array.

import array
from System.Runtime.InteropServices import Marshal

bytes = array.array('c')
bytes.append('a')
bytes.append('b')
bytes.append('c')
Marshal.Copy(bytes, dest, 0, 3)

Is there a way to make this work without copying the data? If not, how do I convert the data in the Python array to the .NET array?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about python