好吧,我一直在使用我的IP Get和console.write函数,但是有一个问题,我不知道Console.Write做什么,我只需要该代码进入Label文本,即当IP获取时,它将转到Label.Text BTW,我使用Visual Studio c#。private void metroLabel1_Click(object sender, EventArgs e) { String strHostName = string.Empty; // Getting Ip address of local machine... // First get the host name of local machine. strHostName = Dns.GetHostName(); Console.WriteLine("Local Machine's Host Name: " + strHostName); // Then using host name, get the IP address list.. IPHostEntry ipEntry = Dns.GetHostEntry(strHostName); IPAddress[] addr = ipEntry.AddressList; for (int i = 0; i < addr.Length; i++) { Console.WriteLine("IP Address {0}: {1} ", i, addr[i].ToString()); //metroLabel1.Text = " >> " + "", i, addr[i].ToString()); // Console.WriteLine = metroLabel1.Text; } Console.ReadLine(); }
添加回答
举报
0/150
提交
取消