代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Diagnostics;
namespace ConsoleApp9
{
class Program
{
static void Main(string[] args)
{
IPHostEntry iPHostEntry = Dns.GetHostEntry("www.baidu.com");
foreach (IPAddress ip in iPHostEntry.AddressList) {
string ipaddress = ip.AddressFamily.ToString();
Console.WriteLine(ipaddress);
Console.WriteLine(ip.ToString());
}
Console.ReadKey();
}
}
}
运行结果