I basically want to know how to write this (Extract all keys from a list of dictionaries) in C#.
I have a list of dictionaries which have all unique keys.
I want to extract all of them into a list of string (as the key is string).
private List<Dictionary<string, string>> dictList = new List<Dictionary<string, string>> { new Dictionary<string, string>() { { "a", "b" } }, new Dictionary<string, string>() { { "c", "d" } }, }; private void GetDictListKeys() { List<string> keyList = new List<string>(); foreach(var dict in dictList) { keyList.Add(dict.Keys.ToString()); } } Thank you.