草庐IT

c# - 如何对自定义类数组进行排序?

我有一个包含2个字符串和1个double(数量)的类。类捐赠者字符串名称字符串注释双倍金额现在我有一个捐赠者数组。如何按金额排序? 最佳答案 如果你实现IComparable你可以这样做:publicclassDonator:IComparable{publicstringname{get;set;}publicstringcomment{get;set;}publicdoubleamount{get;set;}publicintCompareTo(Donatorother){returnamount.CompareTo(other