


private void Form1_Load(object sender, EventArgs e)
{
string s = "";//定义一个变量,用来记录IP地址
System.Net.IPAddress[] addressList = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList;//获取IP地址列表
for (int i = 0; i < addressList.Length; i++)//遍历IP地址列表
{
s += addressList[i].ToString() + "\n";//获得遍历到的IP地址
}
textBox1.Text = s;//显示IP地址
}



亲爱的:若该文章解决了您的问题,可否收藏+评论+分享呢?
文章评论 本文章有个评论