C#: Get a list of every value for a given key in a set of dictionaries?
- by Rosarch
How can I write this code more cleanly/concisely?
/// <summary>
/// Creates a set of valid URIs.
/// </summary>
/// <param name="levelVariantURIDicts">A collection of dictionaries of the form:
/// dict["filePath"] == theFilePath </param>
/// <returns></returns>
private ICollection<string> URIsOfDicts(ICollection<IDictionary<string, string>> levelVariantURIDicts)
{
ICollection<string> result = new HashSet<string>();
foreach (IDictionary<string, string> dict in levelVariantURIDicts)
{
result.Add(dict["filePath"]);
}
return result;
}