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:
NameValueCollection nvc = new NameValueCollection();
nvc.Add("Test", "Val1");
nvc.Add("Test2", "Val1");
nvc.Add("Test2", "Val1");
nvc.Add("Test2", "Val2");
nvc.Add("Test3", "Val1");
nvc.Add("Test4", "Val4");
foreach (string s in nvc)
foreach (string v in nvc.GetValues(s))
Console.WriteLine("{0} {1}", s, v);
Console.ReadLine();
Is there?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…