Why do C# and VB.NET implicitly marshal char* differently?

前端 未结 3 1730
盖世英雄少女心
盖世英雄少女心 2021-02-20 16:19

So I have a function, written in C++, that looks like this...

extern \"C\" __declspec(dllexport) int __stdcall SomeFunction(char *theData)
{
    // stuff
}
         


        
3条回答
  •  情深已故
    2021-02-20 17:11

    Since string is immutable to begin with, I'm guessing that VB somehow wizards the call to allow for the buffer to be modified by the function. Perhaps internally VB is actually passing a StringBuilder as well.

    I wouldn't be surprised if this was a design call by the VB team to make API calls more VB6-like.

提交回复
热议问题