开发者

C++/CLI .ToString() returning error

开发者 https://www.devze.com 2022-12-26 12:31 出处:网络
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:

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() ?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号