我一直试图将C#中的位图数组按字母顺序排列,因为资源没有在resx文件中按字母顺序排列。
我用下面的代码获得了数组的资源
var resourceSet = Properties.Resources.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentUICulture, true, true);
System.Drawing.Bitmap[] imageArray = resourceSet.OfType<DictionaryEntry>()
.Select(i => (System.Drawing.Bitmap)i.Value)
.ToArray();发布于 2014-11-19 20:12:11
您的问题是,在您的Select中,您丢失了要排序的Key。使用匿名类型或新类来保留名称和图像:
var imageArray = resourceSet
.OfType<DictionaryEntry>()
.Select(d =>
new
{
Name = d.Key.ToString(),
Image = (Bitmap)d.Value
})
.OrderBy(d => d.Name);
.ToArray();https://stackoverflow.com/questions/27025736
复制相似问题