有时因为需要,希望知道域名的IP,那用C#怎么实现呢?以下是实现代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
namespace IPSearch
{
class Program
{
static void Main(string[] args)
{
string www = "";
if (args.Length > 0)
{
www = args[0];
if (string.IsNullOrEmpty(www) || string.IsNullOrWhiteSpace(www))
{
Console.WriteLine("Input is empty!");
www = inputWWW();
}
}
else
{
www = inputWWW();
}
Console.WriteLine("Search...");
while (true)
{
IPAddress[] ipAddresses = null;
try
{
ipAddresses = Dns.GetHostAddresses(formatWWW(www));//Important.

本文介绍了如何使用C#进行域名查询IP的操作,包括通过CMD命令参数输入查询和程序启动后输入查询两种方式。详细步骤包括配置环境变量以简化查询过程。
最低0.47元/天 解锁文章
1318

被折叠的 条评论
为什么被折叠?



