删除后添加字典

vas*_*911 0 c# dictionary

我对词典有疑问.我正在使用此代码:

Dictionary<string, string> testDictionary = new Dictionary<string, string>();

testDictionary.Add("1", "1");
testDictionary.Add("2", "2");
testDictionary.Add("3", "3");

testDictionary.Remove("2");

testDictionary.Add("4", "4");
Run Code Online (Sandbox Code Playgroud)

我希望在此之后字典(键和值)为[1,3,4],但它是[1,4,3].我怎样才能做到这一点?

SLa*_*aks 6

字典本质上是无序的.
你不能这样做.