title: Int-Pointer to unmanaged code
body: <p>I'm pretty new to C# and have a simple(?) question. From unmanaged code I receive an int-pointer:</p>
  
  <pre><code>public foo(ref IntPtr state)
  {
     _myState = state;
  }
  </code></pre>
  
  <p><code>_myState</code> is a <code>IntPtr</code> member of the class. Now I want to exchange states via <code>_myState</code> with the unmanaged C++ code. Everything works if I write this:</p>
  
  <pre><code>public foo(ref IntPtr state)
  {
     _myState = state;
     ....do some stuff
     state = 7;
  }
  </code></pre>
  
  <p>In the unmanaged application I can see the new value <code>7</code>. But if I write this:</p>
  
  <pre><code>public foo(ref IntPtr state)
  {
     _myState = state;
     ...do some stuff
     _myState = 7;
  }
  </code></pre>
  
  <p>then nothing happens. The initial value of state is <code>0</code>, and when changing <code>myState</code> to <code>7</code> it is not updated in the unmanaged application.
  How can I assign a member variable like <code>_myState</code> to the state parameter as a "pointer", so when state is updated, <code>_myState</code> is also updated?
  In C++ this would be no problem with a pointer...</p>
  
  <p>Ok, here is the real code:</p>
  
  <pre><code>[DllExport("QFX_InitializeInterfaceObject", CallingConvention = CallingConvention.StdCall)]
      public static void QFX_InitializeInterfaceObject(
          long windowHandle,
          ref IntPtr processState)
      {
          ChartWindowHandle = (IntPtr)windowHandle;
          OrderCommandProcessState = processState;
      }
  </code></pre>
  
  <p>All I want is that <code>OrderCommandProcessState</code> gets the same reference as <code>processState</code> to its value.</p>