Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试从同一网络中的计算机名称获取 IP 地址...类似于 C# Windows 应用程序中的 CMD 命令“nbtstat -a COMPNAME”
使用Dns.GetHostAddresses:
Dns.GetHostAddresses
Dns.GetHostAddresses("some pc name") .ToList() .ForEach(a => Console.WriteLine(a.ToString()));
试试这个方法:
Dns.GetHostName();
http://msdn.microsoft.com/en-us/library/system.net.dns.gethostname.aspx