I haven't touched this one for a long time.
- Through Lambda
- Class temp
- {
- Public int AA;
- }
- Temp T as new temp;
- T. Sort (a, B) =>{ return a. AA. compareto (B. aa );});
Class Temp{Public int AA;}Temp t as new Temp; t.Sort((a, b) => { return a.AA.CompareTo(b.AA); });
- // Anonymous method
- T. AA. Sort (delegate (temp A, temp B)
- {
- Return A. AA. compareto (B. aa );
- });
// The anonymous method T. AA. Sort (delegate (temp A, temp B) {return a. AA. compareto (B. aa );});
- Use the icomparer Interface
- Public class tempcomparison: icomparer <temp>
- {
- Public int compare (temp X, temp y)
- {
- Return X. AA. compareto (Y. aa );
- }
- }
-
- T. AA. Sort (New tempcomparison (). Compare );
public class TempComparison : IComparer<TEMP>{ public int Compare(Temp x, Temp y) { return x.AA.CompareTo(y.AA); }}t.AA.Sort(new TempComparison().Compare);
- Use
- VaR list = from C in T
- Orderby C. AA ascending
- Select C;
var list = from c in t orderby c.AA ascending select c;
- Of course, you can implement the icomparable method.