gpt4 book ai didi

c# - 这种语法有什么问题?

转载 作者:太空宇宙 更新时间:2023-11-03 17:46:20 24 4
gpt4 key购买 nike

    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()},


关于c# - 这种语法有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3125837/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com