看板 C_Sharp 關於我們 聯絡資訊
在C++ dll 程式概述如下: char * test(void) { char testStr[]="Hello World!"; return *testStr; } 在C#宣告如下: static extern byte[] test(void); 在C#使用如下: try { byte[] output = test(); String outputStr = System.Text.Encoding.Default.GetString(output); label1.Text = outputStr; } catch (Exception ex) { label1.Text = ex.ToString(); } -- 簡單來說 我想讓C++ DLL回傳個字串給C#吃 呼叫DLL方面我省篇幅先略掉 確定是沒問題的 因為我用int test(void) 可成功 但是char*/byte[]會有問題 "System.NotSupportedException......" 囧 不知道到哪個環節問題需要更改 感謝大大們指教喔<(_ _)> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.115.235.15
pttlz:我不懂c++和c#,但我建議你試試 static char testStr[]="Hell 11/14 05:12