1
我有一個方法的輸出,每個結果提供兩個關鍵的數據片段。例如:20160503
和nzdusd
。C#按特定值排序的數據結構
我該如何將它存儲在字典中,並對任何一個進行排序? 我希望能夠對鍵或值進行排序,但不能過去添加數據! 有更好的數據結構嗎?
以前我試圖簡單地調用Add()
但有一個ArgumentException
有消息,An item with the same key has already been added.
。
Dictionary<string, string> missingDays = new Dictionary<string, string>();
// Some logic
missingDays.Add(formattedDate, fxPair); // Exception here
foreach (var missingDay in missingDays)
{
Console.WriteLine(missingDay);
}