Csharp/C Sharp/Network/IPHostEntry

Материал из .Net Framework эксперт
Версия от 14:47, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

IPHostEntry.HostName

<source lang="csharp"> using System; using System.Collections.Generic; using System.Text; using System.Net; //DnsLookup class Program {

   static void Main(string[] args) {
       IPHostEntry ipHostEntry = Dns.GetHostEntry("www.google.ru");
       Console.WriteLine("Host: {0}", ipHostEntry.HostName);
       if (ipHostEntry.Aliases.Length > 0) {
           Console.WriteLine("\nAliases:");
           foreach (string alias in ipHostEntry.Aliases) {
               Console.WriteLine(alias);
           }
       }
       Console.WriteLine("\nAddress(es):");
       foreach (IPAddress address in ipHostEntry.AddressList) {
           Console.WriteLine("Address: {0}", address.ToString());
       }
   }

}

</source>