| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1517 人关注过本帖
标题:用C#获取地址!
取消只看楼主 加入收藏
zmfttkl
Rank: 1
等 级:新手上路
帖 子:148
专家分:0
注 册:2007-7-1
收藏
 问题点数:0 回复次数:0 
用C#获取地址!
using System;
using System.Collections.Generic;
using System.Text;
using
namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            ResolveDns resolver1 = new ResolveDns();
            resolver1.Resolve("www.);
            int n = resolver1.IPLength;
            Console.WriteLine("Get the IP Address of the host");
            Console.WriteLine();
            for (int i = 0; i < n; i++)
                Console.WriteLine(resolver1[i]);
            Console.ReadKey();

        }
        class ResolveDns
        {
            IPAddress[] m_ArrayIps;
            public void Resolve(string s_host)
            {
                IPHostEntry ip = Dns.GetHostByName(s_host);
                m_ArrayIps = ip.AddressList;
            }
            public IPAddress this[int nIndex]
            {
                get { return m_ArrayIps[nIndex]; }
            }
            public int IPLength
            {
                get { return m_ArrayIps.Length; }
            }
        }
    }
}
搜索更多相关主题的帖子: 地址 获取 
2007-12-14 15:48
快速回复:用C#获取地址!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030388 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved