C# Iterate through NameValueCollection

后端 未结 7 1796
慢半拍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 02:10

    You can use the key for lookup instead of having two loops:

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

提交回复
热议问题