C# Iterate through NameValueCollection

后端 未结 7 1793
慢半拍i
慢半拍i 2020-12-13 01:43

I have a NameValueCollection, and want to iterate through the values. Currently, I’m doing this, but it seems like there should be a neater way to do it:

7条回答
  •  北海茫月
    2020-12-13 01:53

    foreach ( string key in nvc.Keys )
       Console.WriteLine("{0} {1}", key, nvc[key]);
    

    This will return you all keys and corresponding values.

提交回复
热议问题