title: ByRef vs ByVal performance when passing strings
body: <p>Reading <a href="https://stackoverflow.com/questions/408101/which-is-faster-byval-or-byref">Which is faster? ByVal or ByRef?</a> made me wonder whether the comments in there did apply to <code>Strings</code> in terms of performance. Since strings are copied before being passed, isn't it much more efficient (if the callee doesn't need a copy of string course) to pass strings <code>ByRef</code>?</p>
  
  <p>Thanks,<br>
  CFP.</p>
  
  <p><strong>Edit:</strong> Consider this code, which made me think there was some kind of copy going on:</p>
  
  <pre><code>Sub Main()
      Dim ByValStr As String = "Hello World (ByVal)!"
      Dim ByRefStr As String = "Hello World (ByRef)!"
  
      fooval(ByValStr)
      fooref(ByRefStr)
  
      Console.WriteLine("ByVal: " &amp; ByValStr)
      Console.WriteLine("ByRef: " &amp; ByRefStr)
  
      Console.ReadLine()
  End Sub
  
  
  Sub fooval(ByVal Str As String)
      Str = "foobar"
  End Sub
  
  Sub fooref(ByRef Str As String)
      Str = "foobar"
  End Sub
  </code></pre>
  
  <p>It outputs:</p>
  
  <pre><code>ByVal: Hello World (ByVal)!
  ByRef: foobar
  </code></pre>