How to get all values as a single string from NameValueCollection?

c#, linq, namevaluecollection

Solution

You could use the following:

string allValues = string.Join(System.Environment.NewLine, valueCollection.AllKeys.Select(key => valueCollection[key]));

Problem

How to key all values from `NameValueCollection` as a single string, Now I am using following method to get it: ``` public static string GetAllReasons(NameValueCollection valueCollection) { string _allValues = string.Empty; foreach (var key in valueCollection.AllKeys) _allValues += valueCollection.GetValues(key)[0] + System.Environment.NewLine; return _allValues.TrimEnd(System.Environment.NewLine.ToCharArray()); } ``` Any simple solution using `Linq`?

Original source