public static void PullData(Hashtable source)
    {
        IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
        //IPEndPoint[] endPoints = ipProperties.GetActiveTcpListeners();
        TcpConnectionInformation[] tcpConnections = ipProperties.GetActiveTcpConnections();

        foreach (TcpConnectionInformation info in tcpConnections)
        {
            if (!(info.RemoteEndPoint.Address.ToString() == "192" || info.RemoteEndPoint.Address.ToString() == "127"))
            {
                source.Add(info.RemoteEndPoint.Address.ToString(), new IPInstance(
                  new string[info.LocalEndPoint.Port.ToString(), info.RemoteEndPoint.Port.ToString()],
                  info.RemoteEndPoint.Address.ToString(),
                  Dns.GetHostEntry(info.RemoteEndPoint.Address.ToString())
                  ));
            }
        }
    }


我不断收到错误1无法将类型'string'隐式转换为'int'

最佳答案

看起来你的数组初始化器搞砸了:)

new string[info.LocalEndPoint.Port.ToString(), info.RemoteEndPoint.Port.ToString()],


也许你是说

new string[]{info.LocalEndPoint.Port.ToString(), info.RemoteEndPoint.Port.ToString()},


10-04 12:06
查看更多