[讨论]C#显示本机IP和MAC地址的代码的错误?
下面这段程序为什么不能显示IP地址呢????
编译运行后会在textBox1里显示System.String[],
请问:这是哪里错了呀????????
ManagementClass mc;
mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
//MessageBox.Show(moc.Count.ToString());
foreach (ManagementObject mo in moc)
{
if (mo["IPEnabled"].ToString() == "True")
{
textBox1.Text += mo["IPAddress"].ToString();
textBox2.Text += mo["MACAddress"].ToString();
}
}