title: calling C++/CLI from C# with out parameter
body: <p>Need some references to better understand the <em>out</em> parameter (and the '%' operator used) when interfacing C# with C++/CLI.
  Using VS2012 and this msdn reference:<a href="https://msdn.microsoft.com/en-us/library/h9t2463y(v=vs.110).aspx" rel="nofollow">msdn ref</a></p>
  
  <p>C++ DLL code compiled with /clr</p>
  
  <pre><code>#pragma once
  using namespace System;
  
  namespace MsdnSampleDLL {
  
      public ref class Class1
      {
      public:
          void TestOutString([Runtime::InteropServices::Out] String^ %s) 
          {
              s = "just a string";
          }
          void TestOutByte([Runtime::InteropServices::Out] Byte^ %b) 
          {
              b = (Byte)13;
          }
      };
  }
  </code></pre>
  
  <p>And the C# code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  using MsdnSampleDLL;
  namespace MsdnSampleApp
  {
      class Program
      {
          static void Main(string[] args)
          {
              Class1 cls = new Class1();
              string str;
              cls.TestOutString(out str);
  
              System.Console.WriteLine(str);
  
              Byte aByte = (Byte)3;
              cls.TestOutByte(out aByte);            
          }
      }
  }
  </code></pre>
  
  <p>The string portion of this code (copied from msdn) works fine. But when I tried to expand on the idea with passing a Byte to be filled in - I got the following error from compiling the C#</p>
  
  <blockquote>
    <p>Argument 1: cannot convert from 'out byte' to 'out System.ValueType'</p>
  </blockquote>
  
  <p>So obviously I'm just not "getting it" from the msdn docs. I'd appreciate links to better documentation to explain this.</p>