C++/CLI .ToString()返回错误

Geo*_*ton 2 c++-cli

我是C++/CLI的初学者,因为我来自C#背景.我目前正在编写一些本机C++代码的包装器.我有以下方法:

    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);
    }
Run Code Online (Sandbox Code Playgroud)

...第一种方法工作正常,并将我的字符串转换为字符数组.但是,IPAddress对象作为签名的第二个函数给出了以下错误:

error C2228: left of '.ToString' must have class/struct/union
Run Code Online (Sandbox Code Playgroud)

......当我输入时

? address.ToString() 
Run Code Online (Sandbox Code Playgroud)

...在命令窗口中,打印IP地址.不知道我哪里出错了.有任何想法吗?

And*_*ass 5

address->ToString()