我正在使用C#编写应用程序。在我的应用程序中,我使用以下结构的Dictionary
:
Dictionary<int, string> DataDictionary1 = new Dictionary<int, string>();
我希望字典中的键值可以自动递增。为此,我使用以下逻辑:
string header="ABC";
int maxKey = DataDictionary1 .Max(x => x.Key);
DataDictionary1 .Add(maxKey + 1, header);
这是一种有效的方法吗?因为我想连续执行此操作。是否有其他更快的方法?
System.Collections.Generic.Dictionary<K, V>
的值集合。 - phoog