+ -
当前位置:首页 → 问答吧 → 有关NameValueCollection的代码,求解释

有关NameValueCollection的代码,求解释

时间:2011-12-05

来源:互联网

最近看代码看到一小段代码,硬是没看懂,各位亲们,请指教
private UdpClient client;  
private IPAddress groupAddress;  
private int localPort;  
private int remotePort;  
private int ttl;
private IPEndPoint remoteEP;
try
  { 
  NameValueCollection config = ConfigurationSettings.AppSettings;
  groupAddress = IPAddress.Parse(config["GroupAddress"]);
  localPort = int.Parse(config["LocalPort"]);
  remotePort = int.Parse(config["RemotePort"]);
  ttl = int.Parse(config["TTL"]);
  }
  catch
  {
  MessageBox.Show("读取文件错误!");
  btn_start.Enabled = false;
  }

作者: mzycqu   发布时间: 2011-12-05

哪里不懂?就是读取键/值对
http://msdn.microsoft.com/zh-cn/library/system.collections.specialized.namevaluecollection.aspx

作者: net_lover   发布时间: 2011-12-05

获取config中AppSettings所有的键值对
NameValueCollection config = ConfigurationSettings.AppSettings;
获取某个键值对的值,键值名为GroupAddress
  groupAddress = IPAddress.Parse(config["GroupAddress"]);
  localPort = int.Parse(config["LocalPort"]);
  remotePort = int.Parse(config["RemotePort"]);
  ttl = int.Parse(config["TTL"]);

NameValueCollection
就是键值对,Request就是这样的

作者: jiuhexuan   发布时间: 2011-12-06