由于我的固执,常被朋友叫成"木头鸟",也许有一天"木鸟"也会飞翔... 注册 | 登陆

根据域名取IP地址。

C#代码
  1. public string GetIPByDomain(string url)   
  2. {   
  3.     if (url.Trim() == string.Empty)   
  4.         return "";   
  5.     try  
  6.     {   
  7.         System.Net.IPHostEntry host = System.Net.Dns.GetHostEntry(url);   
  8.         return host.AddressList.GetValue(0).ToString();   
  9.     }   
  10.     catch (Exception e)   
  11.     {   
  12.         throw e;   
  13.     }   
  14. }   

Tags: 域名, ip

« 上一篇 | 下一篇 »

Trackbacks

点击获得Trackback地址,Encode: UTF-8

发表评论

评论内容 (必填):