I have the following code:
string Keys = string.Join(",",FormValues.AllKeys);
I was trying to play around with the get:
string Values = string.Join(",", FormValues.AllKeys.GetValue());
But of course that doesn’t work.
I need something similar to get all the values, but I don’t seem to find the appropriate code to do the same.
P.S: I do not want to use a foreach loop since that beats the purpose of the first line of code.
Also you can create an extension method:
Usage:
Also you can easily convert
NameValueCollectionto more handyDictionary<string,string>so:Gives:
As I found using Reflector,
NameValueCollection.AllKeysinternally performs a loop to gather all te keys, so it seems thatc.Cast<string>()is more preferable.