title: Return parameters from c# to Python
body: <p>I am using PyCharm 2017.1.2 and Visual Studio 2015, I saw the post Jan 27 '14 at 10:58 David Heffernan but could not get it to work.  Parameters work correctly going from c# to Python but not the other way around.  Any thoughts greatly appreciated.  I believe c# should be building a pointer to the string to be returned but the string over in Python is never changed and I cannot seem to use the Visual Studio debugger probably because the c# code is being called from Python.</p>
  
  <pre><code>import threading
  import time
  from ctypes import*
  mydll = cdll.LoadLibrary("C:\\Users\\matthah1\\1data\\Projects\\Europa\\SimpleGUITestDLLClassLibrary1\\SimpleGUITestDLLClassLibrary1\\bin\\x64\\Debug\\SimpleGUITestDLLClassLibrary1.dll")
  global strtest
  strtest = 'empty'
  def startformth():
      mydll.startform()
      print ('leaving startformth')    
  
  ts=threading.Thread(target=startformth)
  ts.daemon = True
  ts.start();
  
  def run_MS_GUI():
      global strtest
  
      strtest2 = "**   "
      testpar=76
      while True: 
          mydll.test(testpar, strtest2)
          print ('after call to test strtest2 in thread:', strtest2)   
          time.sleep(1)
  
  
  
  t=threading.Thread(target=run_MS_GUI )
  t.daemon = True
  t.start()
  for i in range(40):
     #print ('looping for test strtest  is:', strtest)
     time.sleep(1)
  t.stop()
  ts.stop()
  
  
  
      [DllExport("test", CallingConvention = CallingConvention.Cdecl)]
  
      static public int test(int testpar, IntPtr par3)
      {
  
  
          testpar = testpar + 1;
          testparfromPythong = testpar;
          string inputStr = Marshal.PtrToStringAnsi(par3);
          string outputStr = "foo\0";
          byte[] outputBytes = Encoding.ASCII.GetBytes(outputStr);
          Marshal.Copy(outputBytes, 0, par3, outputBytes.Length);
  
          return 0;
  
      }
  </code></pre>