close
Array 的型態是可以自訂排序的
範例
public class ReverseComparer: IComparer<string>
{
public int Compare(string x, string y)
{
return y.CompareTo(x);
}
}
public static void Main()
{
string[] dinosaurs = {"P", "A", "T", "M", "D", "E"};
ReverseComparer rc = new ReverseComparer();
Array.Sort(dinosaurs, rc);
}
結果會變成 T,P,M,E,D,A
全站熱搜
留言列表