📄 program.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Threading;
namespace AsynGetHostByName
{
class Program
{
static void Main(string[] args)
{
AsyncCallback OnResolved;
object state = new Object();
OnResolved = new AsyncCallback(Resolved);
Dns.BeginGetHostByName(args[0], OnResolved, state);
Console.ReadKey();
}
private static void Resolved(IAsyncResult ar)
{
IPHostEntry iphe = Dns.EndGetHostByName(ar);
IPAddress[] address = iphe.AddressList;
// Get the alias names of the addresses in the IP address list.
String[] alias = iphe.Aliases;
Console.WriteLine("Canonical host name : " + iphe.HostName);
Console.WriteLine("\nAliases : ");
for (int index = 0; index < alias.Length; index++)
{
Console.WriteLine(alias[index]);
}
Console.WriteLine("\nIP address list : ");
for (int index = 0; index < address.Length; index++)
{
Console.WriteLine(address[index]);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -