将 IP 地址(int)解析为名称

Lyn*_*ynx 3 c# string ip dns

可能的重复:
如何从 C# 中的给定 IP 获取域名?

如何将 int 格式的 ip 地址转换为字符串格式。例如,我有 int 格式的这个 ip 地址,173.194.38.138我想转换为 string www.rugadingku.blogspot.com。我看到了很多关于如何将 ip string 转换为 int,但没有将 int 转换为 string 的示例。

Sir*_*ifi 5

您可以使用此代码将 IP 地址转换为 HostName :

IPHostEntry IpToDomainName = Dns.GetHostEntry("173.194.38.138");
string hostname =IpToDomainName.HostName;
Run Code Online (Sandbox Code Playgroud)

Dns.GetHostByAddress

你也可以用这种方式:

 System.Net.IPHostEntry ip = System.Net.Dns.GetHostByAddress("173.194.38.138");
 string hostname = ip.HostName;
Run Code Online (Sandbox Code Playgroud)