Quote:
引用第3楼zc1984于2006-11-03 20:48发表的:
因为你调用的是GetValue()
而不是GetValues()
所以返回值只是一个string对象,而不是string[]
clear?
不clear
Quote:
msdn
string[] tArray = (string[]) Registry.GetValue(keyName,
"TestArray",
new string[] {"Default if TestArray does not exist."});
改成 string ipaddress = Convert.ToString(networkKey.GetValue("DhcpIPAddress"));
string defaultGateway = Convert.ToString(networkKey.GetValue("DhcpDefaultGateway"));
string subnetmask = Convert.ToString(networkKey.GetValue("DhcpSubnetMask"));
Console.WriteLine("IP Address : {0}", ipaddress);
Console.WriteLine("Subnet Mask : {0}", subnetmask);
Console.WriteLine("Gateway : {0}", defaultGateway);
这样就可以了
但是结果却是
Network card: Realtek RTL81
IP Address : 172.24.17.66
Subnet Mask : 255.255.224.0
Gateway : System.String[]