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

Cod*_*awk 2 c# resources asp.net-3.5

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

提前谢谢了 :)

Man*_*dra 7

ressource集有一个IDictionaryEnumerator,所以我猜它的项类型为DictionaryEntry,尝试按如下方式对数据源进行排序:

DropDownList1.DataSource = Resources.FileTypes.ResourceManager
    .GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true)
    .OfType<DictionaryEntry>()
    .OrderBy(i => i.Value);
Run Code Online (Sandbox Code Playgroud)

嗯,我没有打开视觉工作室,所以不要责怪我万一它不能立即工作:)