Get keys from IList<IDictionary<string, object>>

I have

IList<IDictionary<string, object>> 

How get without duplication keys from all of dictionaries inside this IList and put them to IList<string> using LINQ?

Upvotes: 4

Views: 591

Answers (1)

Dennis
Dennis

Reputation: 37770

Use SelectMany and Distinct

List<string> uniquekeys = listOfDictionaries
    .SelectMany(d => d.Keys)
    .Distinct()
    .ToList();

Upvotes: 10

Related Questions