/*C++*/ int __declspec(dllexport) foo(char* buf, int n) { strncpy(buf, glb.c_str(), n); return min(glb.size(), n); }
/*C#*/ [DllImport("hoge.dll", CharSet=CharSet.Auto, ExactSpelling=true)] public static extern int foo(StringBuilder buf, int n);
こうか? 合ってるかは知らん