我如何获得某些特定ID的用户 [英] How Can I Get The Users Of Some Specific Id
本文介绍了我如何获得某些特定ID的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如果任何ip是免费的,我怎样才能获得ips的用户它会抛出错误没有这样的主机已知
i want to know how can i get the users of the ips if any ip is free the it throws an error "No such host is known"
string ip1 = "10.236.105.108";
string ip2 = "10.236.105.208";
string st = Convert.ToString(ip1.Substring(ip1.LastIndexOf('.') + 1));
string lt = Convert.ToString(ip2.Substring(ip2.LastIndexOf('.') + 1));
for (int i = Convert.ToInt32(st); i <= Convert.ToInt32(lt); i++)
{
string addr = ip1.Substring(0, ip1.LastIndexOf('.')) + '.' + i;
IPHostEntry entry = Dns.GetHostEntry(addr);
}
推荐答案
这是正确的,请参阅http://msdn.microsoft.com/en-us/library/ms143998(v=vs.110)。 aspx [ ^ 。你只需要捕获异常,如果它是一个未知的地址,那么忽略它并继续下一个。
That is correct, see the Remarks section at http://msdn.microsoft.com/en-us/library/ms143998(v=vs.110).aspx[^]. You just need to catch the exception and if it is an unknown address then ignore it and go on to the next one.
这篇关于我如何获得某些特定ID的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文