且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将C#字符串转换为c ++字符串的正确方法

更新时间:2023-02-12 15:53:24

你好,


这对你有帮助吗?
https://***.com/questions/1300718/c-net- convert-systemstring-to-stdstring


此致,Guido


Hi everyone,

I know. This question has been asked several times on the Net but I'm looking for a way to avoid the [declspec] thing.

Because I have made a .dll of my C++ project and added that .dll file as a reference to my C# project. Now If I'm honest I don't quite know how to pass over a c# string to a c++ string. I have tried alot of things but it's not working until now.

C# code:

[...]
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    strToSend = dlg.SelectedPath;
                    obj.SetString(strToSend);

                }
[...]

C++ code:

[...]

void OpenCvWrapper::SetString(string s) { //do stuff with string }

[...]

Is there another way?

Thanks,

Andries

Hello,

does this help you ? https://***.com/questions/1300718/c-net-convert-systemstring-to-stdstring

Regards, Guido