好的......这是一个垒球问题......
我只需要能够将键/值对插入到特定位置的对象中.我目前正在使用Hashtable,当然,这不允许使用此功能.什么是最好的方法?
更新:此外,我确实需要能够通过密钥查找.
例如......过度简化和伪编码但应该传达这一点
// existing Hashtable
myHashtable.Add("somekey1", "somevalue1");
myHashtable.Add("somekey2", "somevalue2");
myHashtable.Add("somekey3", "somevalue3");
// Some other object that will allow me to insert a new key/value pair.
// Assume that this object has been populated with the above key/value pairs.
oSomeObject.Insert("newfirstkey","newfirstvalue");
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我有一个名为filetypes.resx的资源文件.一些我如何计算出将资源值绑定到dropdownlist,但我不知道如何对ResourceSet的值进行排序.
这是我到目前为止所做的,
FileTypes.resx
A,1
B,2
C,3
用于绑定下拉列表的代码
DropDownList1.DataSource = Resources.FileTypes.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
DropDownList1.DataTextField = "Key";
DropDownList1.DataValueField = "Value";
DropDownList1.DataBind();
Run Code Online (Sandbox Code Playgroud)
结果
A C B
As you can see the result is not sorted. Please help me to solve this issue.
Run Code Online (Sandbox Code Playgroud)
提前谢谢了 :)