title: How to pass managed reference to unmanaged code in C++/CLI?
body: <p>I'm using C++/CLI only to unit test unmanaged C++ code in VS2010. I switched the compiler to /clr and using the unmanaged code from a static library.</p>
  
  <p>I have a simple <code>int</code> property in my test class.
  I would like to pass that as a <code>const int &amp;</code> to a function in native C++. But it can't compile and I've found out that, it's because you can't mix references like that.</p>
  
  <p>What is the way to do it, I tried to following and it's working, but is there a nicer way?</p>
  
  <pre><code>[TestClass]
  public ref class MyTestClass
  {
  private:
      int _my_property;
  public:
  
      [TestMethod]
      void MyTestMethod()
      {
          MyNativeClass c;
          // c.SomeMethod(_my_property) this doesn't work
  
          int i = _my__property;
          c.SomeMethod(i) // this works
      }
  }
  </code></pre>