I am a beginner to C++/CLI as I come from a C# background. I am currently writing a wrapper for some native C++ code. I have the following methods:
void AddToBlockList(System::String^ address)
{
char* cAddress = (char*)(void*)Marshal::StringToHGlobalAnsi(address);
_packetFilter->AddToBlockList(cAddress);
}
void AddToBlockList(IPAddress^ address)
{
char* cAddress = (char*)(void*)Marshal::StringToHGlobalAnsi(address.ToString());
_packetFilter->AddToBlockList(cAddress);
}
...The first method works fine and converts my string into the character array开发者_开发百科. However, the second function with the IPAddress object as the signiture gives me the following error:
error C2228: left of '.ToString' must have class/struct/union
...When I type
? address.ToString()
...in the command window, the IP Address prints. Not sure where I'm going wrong. Any ideas?
address->ToString()
?
精彩评论