相关疑难解决方法(0)

如何将项插入键/值对对象?

好的......这是一个垒球问题......

我只需要能够将键/值对插入到特定位置的对象中.我目前正在使用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)

提前致谢.

c# list insert

62
推荐指数
3
解决办法
16万
查看次数

如何在C#中对ResourceSet进行排序

我有一个名为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)

提前谢谢了 :)

c# resources asp.net-3.5

2
推荐指数
1
解决办法
4758
查看次数

标签 统计

c# ×2

asp.net-3.5 ×1

insert ×1

list ×1

resources ×1