我有一个实体。
public class ContextElements
{
public string Property { get; set; }
public string Value { get; set; }
}
现在,我已经把该实体归入下级(这是对网上服务提供的实际投入的模拟)。
var collection = new List<ContextElements>();
collection.Add(new ContextElements { Property = "Culture", Value = "en-US" });
collection.Add(new ContextElements { Property = "Affiliate", Value = "0" });
collection.Add(new ContextElements { Property = "EmailAddress", Value = "[email protected]" });
collection.Add(new ContextElements { Property = "Culture", Value = "fr-FR" });
collection.Add(new ContextElements { Property = "Affiliate", Value = "1" });
collection.Add(new ContextElements { Property = "EmailAddress", Value = "[email protected]" });
现在,我有一句dict语。
Dictionary<string, List<string>> dictStr = new Dictionary<string, List<string>>();
我所期待的产出是,对于这里的“Culture”、“Affiliate”、“Email Address”等每个特定关键(即财产)来说,这些数值将出现在清单收集中。
i.e. 字典的最终产出是以下产出(显然在操作和编程上)
dictStr.Add("Culture", new List<string>() { "en-US", "fr-FR" });
dictStr.Add("Affiliate", new List<string>() { "0","1" });
dictStr.Add("EmailAddress", new List<string>() { "[email protected]", "[email protected]"
});
所需帮助
Thanks