I am building a c# application, in my application, I load a c++/cli dll, and calling its function.
I have declare a value class in my c++/cli class.
public value class S_OpenParam {
public :
int iPort;
char* szIpAddress;
int iBaudRate;
};
Then , I am trying to initialize my S_OpenParam in my c# application.
I am facing problem on initialize the char* szIpAddress
myObj.S_OpenParam sParam;
sParam.iBaudRate = 0;
sParam.iPort = 0;
When I try to assign a value to it:
sParam.szIpAddress = "127.0.0.1";
It shows the type is sbyte*
Do you know how to initialize it ?

publicmust useString^instead ofchar*. It is up to your C++/CLI code, if necessary, to convert that System::String to a legacy encoding. Not making that necessary is easy too, encoding an IP address in an 8-bit string is something you had to do 25 years ago. We're in the 21st century today.