c# 根据域名的到对应的IP

    今天做了域名解析,由于项目里要用到域名对应的ip 所以做了这个小程序

private void button_Net_Click(object sender, EventArgs e)
        {
            IPHostEntry hostinfo = Dns.GetHostEntry(textBox_Net.Text.Trim());//输入域名
            //IPHostEntry hostinfo = Dns.GetHostByName(textBox_Net.Text.Trim());
            IPAddress[] aryIP = hostinfo.AddressList;
            string result = aryIP[0].ToString();
            textBox_IP.Text = result;

        }

原文地址:https://www.cnblogs.com/hanjiaxu/p/3230319.html