最近看代码看到一小段代码,硬是没看懂,各位亲们,请指教
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;
            }

解决方案 »

  1.   

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

  2.   

    获取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就是这样的