Creating the IEnumerable<KeyValuePair<string, string>> Objects with C#?
any of:
values = new Dictionary<string,string> { {"Name", "John"}, {"City", "NY"} };
or
values = new [] {
new KeyValuePair<string,string>("Name","John"),
new KeyValuePair<string,string>("City","NY")
};
or:
values = (new[] {
new {Key = "Name", Value = "John"},
new {Key = "City", Value = "NY"}
}).ToDictionary(x => x.Key, x => x.Value);
Dictionary<string, string>
implements IEnumerable<KeyValuePair<string,string>>
.
var List = new List<KeyValuePair<String, String>> {
new KeyValuePair<String, String>("Name", "John"),
new KeyValuePair<String, String>("City" , "NY")
};