I am trying to use my C++ class in my C# program. So I made a .dll-file to use it in C#. My problem is, that I am working with strings. My question is: How can I return a std::string to my C# program?
My C++ class (header-file):
using namespace std;
class CComPort
{
public:
string ReadLine();
void WriteLine(string userInput);
};
My dll code:
string CppWrapper::CComPortWrapper::ReadLineWrapper()
{
return comPort->ReadLine();
}
void CppWrapper::CComPortWrapper::WriteLineWrapper(string userInput)
{
comPort->WriteLine(userInput);
}
My C#-Code:
comPort.WriteLineWrapper(tb_send.Text);
Error:
'CComPortWrapper.WriteLineWrapper(?,?)' is not supported by the language.
I tried to change the dll file to something like this, but it didn't worked:
void CppWrapper::CComPortWrapper::WriteLineWrapper(String ^ userInput)
{
comPort->WriteLine(userInput);
}
What is the rigth way to change it?