Có thể ngầm tuyên bố tiếp theo Dictionary<HyperLink, Anonymous>
:Anonymous initializer bộ sưu tập cho một cuốn từ điển
{ urlA, new { Text = "TextA", Url = "UrlA" } },
{ urlB, new { Text = "TextB", Url = "UrlB" } }
vì vậy tôi có thể sử dụng nó theo cách này:
foreach (var k in dic)
{
k.Key.Text = k.Value.Text;
k.Key.NavigateUrl = k.Value.Url;
}
?
bản sao có thể có của [Từ điển có giá trị là một loại ẩn danh trong C#] (http://stackoverflow.com/questions/1619518/a-dictionary-where-value-is-an-anonymous-type-in-c -sharp) – nawfal