title: How to convert optional pointer argument from C++ code to C#
body: <p>I have function in c++ something like this:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>// C++
  bool Foo(int* retVal = NULL)
  {
      // ...
      if (retVal != NULL)
          *retVal = 5;
      // ...
      return true;
  }
  </code></pre>
  
  <p>And I can use functions in two ways:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>int ret;
  Foo(&amp;ret);
  
  Foo();
  </code></pre>
  
  <p>When I write code in C# I used ref keyword:</p>
  
  <pre class="lang-cs prettyprint-override"><code>// C#
  bool Foo(ref int retVal = null)
  {
      // ...
      if (retVal != null)
      {
          retVal = 5;
      }
      // ...
      return true;
  }
  </code></pre>
  
  <p>but compiler said:</p>
  
  <p><strong><em>A ref or out parameter cannot have a default value.</em></strong></p>
  
  <p>How can I solve this problem?</p>