根据对象的属性对一组强类型对象进行排序 [英] Sort an array of strongly typed objects based on a property of the object
本文介绍了根据对象的属性对一组强类型对象进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 array []
对象,由于某些原因,我不能将其更改为 List<>
,是否可以基于对象的1字段中的值对对象的 array []
进行排序?
I have an array[]
of objects, for certain reasons I cannot change it to a List<>
, is it possible to sort on the array[]
of objects, based on a value in 1 field of the object?
例如
arrayOfFruit[] fruit;
fruit.sort(name);
推荐答案
使用Array .. ::。Sort方法(数组,IComparer)
Use Array..::.Sort Method (Array, IComparer)
http://msdn.microsoft.com/zh-CN/library/aw9s5t8f.aspx
这篇关于根据对象的属性对一组强类型对象进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文