c# - C# - 网络设备列表
问题描述
我应该显示本地网络中的所有笔记本电脑。我试过这个:
public static int GetAllIP(string[] args = null)
{
string strHostName = new string("");
if (args.Length == 0) {
strHostName = DNS.GetHostName();
Console.WriteLine("Local Machine's Host Name: " + strHostName);
} else {
strHostName = args[0];
}
IPHostEntry ipEntry = DNS.GetHostByName(strHostName);
IPAddress[] addr = ipEntry.AddressList;
int i = 0;
while (i < addr.Length) {
Console.WriteLine("IP Address {0}: {1} ", i, addr(i).ToString());
System.Math.Max(System.Threading.Interlocked.Increment(ref i), i - 1);
}
return 0;
}
我也试过这个,也不行。我的意思是,我总是得到一个空数组。
任何其他想法如何做到这一点?
解决方案
推荐阅读
- sql - 对具有不同时间的相同部件集合中最早的数据进行排序
- java - 如何创建连接管理器并以多种方式处理查询结果?(爪哇)
- android - 移动应用程序中的管理面板 || 如何添加和隐藏本地用户 || 反应原生 || 安卓
- vba - 如何应用粗体和项目符号?
- visual-studio - 调试不适用于带有 Visual Studio 的 docker compose
- reactjs - 如何处理未经授权的用户并将其重定向到 Reactjs 中的 403 页面
- wso2 - 如何更新 SAML WSO2 身份服务器
- r-markdown - r 脚本中的源 .Rmd
- sql-server - 即使连接条件匹配,第二个左外连接也不返回结果集中的行
- java - 具有相同性能的内循环(易碎)替代方案