title: Why do C# and VB.NET implicitly marshal char* differently?
body: <p>So I have a function, written in C++, that looks like this...</p>
  
  <pre><code>extern "C" __declspec(dllexport) int __stdcall SomeFunction(char *theData)
  {
      // stuff
  }
  </code></pre>
  
  <p>... and I'm using it in my current project (written in C#). There are other projects that use this function written in VB, looking like this:</p>
  
  <pre><code>Public Declare Function SomeFunction Lib "MyDLL.dll" _
      Alias "_SomeFunction@4" (ByVal theData As String) As Integer
  </code></pre>
  
  <p>So I tried writing an equivalent in C#, but found that using the string type didn't actually work for me - the string would come back with the same data I passed it in with. I tried using <code>"ref string"</code> instead to pass the string by reference and I got a memory access violation.</p>
  
  <p>After doing some digging, I found that this was the correct implementation in C#:</p>
  
  <pre><code>[DllImport("MyDLL.dll", EntryPoint = "_SomeFunction@4")]
  public static extern int SomeFunction(StringBuilder theData);
  </code></pre>
  
  <p>Now I know that VB.NET and C# are quite different, but I suppose I always assumed that strings were strings. If one language can marshal <code>char*</code> to <code>String</code> implicitly, why can't the other, requiring a different class altogether?</p>
  
  <p>(edited the title for clarity)</p>