How to use a .NET method which modifies in place in Python?

后端 未结 2 889
情深已故
情深已故 2020-12-17 02:42

I am trying to use a .NET dll in Python. In a .NET language the method requires passing it 2 arrays by reference which it then modifies:

public void GetItems         


        
2条回答
  •  囚心锁ツ
    2020-12-17 03:31

    I have managed to use the method bool XferData(ref byte[] buf, ref int len) from C# library CyUSB.dll with the following code:

    >>> xferLen = 2;
    
    >>> outData=[10, 0]
    
    >>> inData=[]
    
    >>> n, outData, xferLen = XferData(outData, xferLen)
    
    >>> print n, outData[0], outData[1], xferLen
    
    True 10 0 2
    

    Hope this helps someone.

提交回复
热议问题